# Iota

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

## Overview

IOTA is the native asset of the Iota blockchain. It utilizes:

- Object (UTXO like) model
- EdDSA signature algorithm

Iota is a Layer 1 IOTA blockchain designed for full decentralization, scalability, and enhanced security. It leverages the Move programming language to enhance smart contract safety and performance. Iota aims to provide a high-throughput, low-latency blockchain for decentralized applications (dApps), DeFi, NFTs, and institutional use cases.

## Explorer

<a href="https://explorer.iota.org/" target="_blank" rel="noreferrer">https://explorer.iota.org/</a>

## Wallets Types

BitGo enables holding Iota in the following wallet types:

| | Multisig Cold | Multisig Hot | MPC Cold | MPC Hot |
|-| ------------- | ------------ | -------- | ------- |
| **Custody** |  ❌ | N/A | ✅ | N/A |
| **Self-Custody** | ❌ | ❌ | ✅ | ✅ |

## Ticker Symbols

| Mainnet | Testnet |
| ------- | ------- |
| iota | tiota |

## Faucet

You can use a faucet to obtain free testnet Iota for development and testing purposes.

**Faucet:** <a href="https://docs.iota.org/developer/getting-started/get-coins" target="_blank" rel="noreferrer">https://docs.iota.org/developer/getting-started/get-coins</a>

## Units

Iota is divisible by 10<sup>-9</sup> and the base unit is called NANO :

- 1 Iota = 1000000000 NANO
- 1 NANO = 0.0000000001 IOTA

Iota balances can be in either integer or string format. However, BitGo recommends using string format to ensure values don't exceed the programmable number limit.

## Tokens

The Iota blockchain natively support tokens. Bitgo currently does not support Iota tokens.

## Fees

Every IOTA transaction-whether involving **tokens or native coin**, and whether a **withdrawal or consolidation**—must pay a gas fee. Both the execution & IO costs and storage costs determine this fee.
Learn more about Iota [gas pricing](https://docs.iota.org/about-iota/tokenomics/gas-pricing)

## Create Wallet

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tiota"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export LABEL="<DESIRED_WALLET_NAME>"
export PASSPHRASE="<YOUR_BITGO_LOGIN_PASSPHRASE>"
export ENTERPRISE_ID="<YOUR_ENTERPRISE_ID>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/generate \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "label": "'"$LABEL"'",
    "passphrase": "'"$PASSPHRASE"'",
    "enterprise": "'"$ENTERPRISE_ID"'",
    "disableTransactionNotifications": true,
    "disableKRSEmail": true
}'
```
```js JavaScript
const { BitGo } = require('bitgo');

const accessToken = '<YOUR_ACCESS_TOKEN>';

// Initialize the SDK
const bitgo = new BitGo({
accessToken: accessToken,
env: 'test',
});

// Generate hot wallet
async function createHotWalletSimple() {
const newWallet = await bitgo.coin('[testnet ID all lowercase]').wallets().generateWallet({
    label: '<DESIRED_WALLET_NAME>',
    passphrase: '<YOUR_BITGO_LOGIN_PASSWORD>',
});

console.log(JSON.stringify(newWallet, undefined, 2));
}
```

## Create Address

```shell cURL
export COIN="tiota"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"

curl -X POST \
  https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/address \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
```js JavaScript
const { BitGo } = require('bitgo');
const accessToken = '<YOUR_ACCESS_TOKEN>';

// Initialize the SDK
const bitgo = new BitGo({
  accessToken: accessToken,
  env: 'custom',
  customRootURI: 'https://app.bitgo.com',
});

// Create address
const wallet = await bitgo.coin('tiota').wallets().generateWallet({
  label: '<DESIRED_WALLET_NAME>',
  passphrase: '<YOUR_BITGO_LOGIN_PASSPHRASE>',
});

const address = await wallet.createAddress(
);

// Print address details
console.log(JSON.stringify(address, undefined, 2));
```

> 📘 **Note:** Iota does not require a minimum balance for receiving addresses]

## Consolidate Balance

[Select 1 of the following statements depending on the asset type:]

[Iota is an object-based asset that requires consolidating to the base address to use the maximum spendable amount. The following code samples consolidate using the [Consolidate account (simple)](/reference/expresswalletconsolidateaccount) endpoint:]

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tiota"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export ADDRESS_1="<DESTINATION_ADDRESS_1>"
export ADDRESS_2="<DESTINATION_ADDRESS_2>"
export WALLET_PASSPHRASE="<YOUR_WALLET_PASSPHRASE>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/consolidateAccount \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "consolidateAddresses": [
    {
      "address": "'"$ADDRESS_1"'"
    },
    {
      "address": "'"$ADDRESS_2"'"
    }
  ],
    "walletPassphrase": "'"$WALLET_PASSPHRASE"'"
}'
```
```js JavaScript
const BitGoJS = require('bitgo');
const Promise = require('bluebird');

const bitgo = new BitGoJS.BitGo({ env: 'test' });

const coin = 'tiota';

// Enter your wallet ID
const walletId = '<YOUR_WALLET_ID>';

// Enter your wallet passphrase
const walletPassphrase = '<YOUR_WALLET_PASSPHRASE>';

// Enter OTP code
const otp = '<YOUR_OTP>';

// Enter your access token
  bitgo.authenticateWithAccessToken({ accessToken });

  const wallet = await bitgo.coin(coin).wallets().get({ id: walletId });
  // Base address
  console.log('Base Address:', wallet.coinSpecific().baseAddress);
  // Confirmed balance - sum of the balances of all the addresses
  console.log('Confirmed Balance:', wallet.confirmedBalanceString());
  // Spendable balance - balance of the base address
  console.log('Spendable Balance:', wallet.spendableBalanceString());

  const consolidationTxes = await wallet.buildAccountConsolidations();

  try {
    for (const unsignedConsolidation of consolidationTxes) {
      const res = await wallet.sendAccountConsolidation({ walletPassphrase, prebuildTx: unsignedConsolidation });
      console.dir(res, { depth: 6 });
    }
  } catch (e) {
    console.error(e);
  }
);
```

## Transact

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tiota"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export ADDRESS="<DESTINATION_ADDRESS>"
export AMOUNT="<AMOUNT_IN_BASE_UNITS>"
export WALLET_PASSPHRASE="<YOUR_WALLET_PASSPHRASE>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/sendcoins \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "address": "'"$ADDRESS"'",
    "amount": "'"$AMOUNT"'",
    "walletPassphrase": "'"$WALLET_PASSPHRASE"'"
}'
```
```shell cURL (send to many)
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tiota"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export ADDRESS_1="<DESTINATION_ADDRESS_1>"
export ADDRESS_2="<DESTINATION_ADDRESS_2>"
export AMOUNT_1="<AMOUNT_1_IN_BASE_UNITS>"
export AMOUNT_2="<AMOUNT_2_IN_BASE_UNITS>"
export WALLET_PASSPHRASE="<YOUR_WALLET_PASSPHRASE>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/sendmany \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "recipients": [
    {
      "address": "'"$ADDRESS_1"'",
      "amount": "'"$AMOUNT_1"'"
    },
    {
      "address": "'"$ADDRESS_2"'",
      "amount": "'"$AMOUNT_2"'"
    }
  ],
    "walletPassphrase": "'"$WALLET_PASSPHRASE"'"
}'
```
```js JavaScript
const tx = await fundedWallet.send({
    address: `<DESTINATION_ADDRESS>`,
    amount: `<AMOUNT>`,
    walletPassphrase: process.env.PASSWORD as string,
  });
```
```js JavaScript (send to many)
let params = {
  recipients: [
    {
      amount: "<AMOUNT_1>",
      address: "<DESTINATION_ADDRESS_1>",
    },
    {
      amount: "<AMOUNT_2>",
      address: "<DESTINATION_ADDRESS_2>",
    },
  ],
  walletPassphrase: "<YOUR_WALLET_PASSPHRASE>",
};
wallet.sendMany(params).then(function (transaction) {
  // Print transaction details
  console.dir(transaction);
});
```

## Stake

Bitgo doesn't support Iota staking yet.
