# Casper

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

## Casper

<a href="https://docs.casper.network/" target="_blank" rel="noreferrer">Casper</a> can be accessed with the following coin types:

| Environment       | Coin Type | Faucet                                                                                                                       |
| :---------------- | :-------- | :--------------------------------------------------------------------------------------------------------------------------- |
| Casper Production | cspr      |                                                                                                                              |
| Casper Testnet    | tcspr     | <a href="https://integration.cspr.live/tools/faucet" target="_blank" rel="noreferrer">https://integration.cspr.live/tools/faucet</a> |

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


### Generating wallets

```javascript
bitgo
  .coin('tcspr')
  .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/tcspr/wallet/generate
```

Before you can use a Casper wallet, it must be initialized on the Casper 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 Casper wallet during initialization or you may lose assets.

Casper accounts must maintain a minimum balance. See the **Balance** section below.

### Required reserve

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

Fetch information about reserve requirements for an account. See the **Balance** section below.

#### HTTP Request

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

#### Response

| Field          | Description                                                     |
| :------------- | :-------------------------------------------------------------- |
| baseFee        | Base fee used in transaction fees.                              |
| baseReserve    | Base reserve used in minimum account balances.                  |
| height         | 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('tcspr')
  .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/tcspr/wallet/$WALLET/address
```

Casper wallet addresses differ by a sequentially incremented transferId (because they cannot leverage the BIP-32 standard). The transferId type used by BitGo is `TRANSFER_ID`: a 64-bit unsigned numeric string.

When BitGo creates a new address, it returns the incremented `transferId` and the `rootAddress` in the `coinSpecific`
property.

### Balances

Casper (CSPR) the native asset of the Casper blockchain. The base unit of Casper is the mote:

- 1 mote is <code>10<sup>-9</sup></code> or 0.000000001 Casper.
- 1 Casper is <code>10<sup>9</sup></code> or 1000000000 motes (1 billion).

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

Casper accounts must maintain a minimum balance, calculated by adding a base reserve and a base fee. Currently,
the base reserve is 2.5 CSPR and the base fee is 1 CSPR so the minimum balance required is 3.5 CSPR.

### Transactions

Casper uses an account-based model like XLM and XRP. But instead of using XLM's `memo` or XRP's destination tag, Casper
uses `transferId`.

Currently, the fixed fee is 10,000 motes `(0.0001 CSPR)`. And the minimum amount for a transaction is 2.5 CSPR.

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

### Staking

Casper provides staking service through smart contracts.
Staking and unstaking requests require an active validator and an amount greater or equal to 2.5 CSPR to be provided.

Currently, the fees for staking and unstaking are 5 CSPR for both.
