# RSK Smart Bitcoin

Source: https://developers.bitgo.com/docs/rsk-smart-bitcoin

## RSK Smart Bitcoin

> 📘 **Note:** RSK was formerly known as Rootstock

RSK Smart Bitcoin can be accessed with the following coin types:

| Environment    | Coin Type | Faucet                                                                                       |
| :------------- | :-------- | :------------------------------------------------------------------------------------------- |
| RSK Production | rbtc      |                                                                                              |
| RSK Testnet    | trbtc     | <a href="https://faucet.rootstock.io" target="_blank" rel="noreferrer">https://faucet.rootstock.io</a> |

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


### Enterprise fee address

```shell
ENTERPRISEID=585c51a5df8380e0e3082e46

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

RSK uses the same fee address structure as Ethereum.

Each enterprise has a fee address used to pay for transaction fees on all RSK wallets in that enterprise.
The dashboard of the BitGo website displays the fee address, and you must fund it before creating a wallet,
address, or sending a transaction. 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 RSK
wallets to fund the fee address if the fee address is too low (because you cannot send transactions from
your RSK wallet). It is best to create and fund a non-BitGo RSK account, so you can use it to fund your BitGo
enterprise fee address. Any open source RSK wallet can be used to create an account.

> 📘 **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 RSK wallets. Use this address to pay the
fees for creating transactions and addresses.

### Generating wallets

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

Before you can use an RSK wallet, it must be initialized on the RSK blockchain. When you create an RSK wallet, BitGo
sends a transaction on the RSK network to generate the wallet.

Until the initialization transaction confirms, 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 RSK wallet during initialization or you may lose assets.

### Creating addresses

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

RSK address creation requires interactions with the RSK blockchain. To deploy a receive address contract, BitGo
sends a transaction on the RSK network. Make sure to fund the fee address mentioned earlier. Like the wallet creation
process, a RSK address does not become usable immediately upon creation and so the caller of this function needs to wait
for the initialization transaction to be confirmed before attempting to fetch, or send to, the address.

### Balances

Smart Bitcoin (RBTC) is the native asset of the RSK blockchain and maintains a 1:1 peg to BTC. RSK is a smart-contract
compatible Bitcoin sidechain and uses the Ethereum Virtual Machine (EVM).

RBTC is used to pay for RSK gas fees like Ether is used to pay for Ethereum gas fees. The base unit of Smart Bitcoin is
wei:

- 1 wei is (<code>10<sup>-18</sup></code>) or 0.000000000000000001 RSK.
- 1 RSK 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 RSK multisig contract currently only supports one sender and one recipient. That means that the `sendMany` call
only accepts one recipient.
