# Vechain

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

## Overview

Vechain (VET) is the native asset of the Vechain blockchain. It utilizes:

- Account model
- ECDSA signature algorithm

VeChainThor is the layer 1 blockchain which powers the VeChain ecosystem. VeChainThor is a public blockchain that targets mass adoption and serves as a foundation for a sustainable and scalable blockchain ecosystem.

## Explorer

<a href="https://explore.vechain.org/" target="_blank" rel="noreferrer">https://explore.vechain.org/</a>

## Wallets Types

BitGo enables holding Vechain in the following wallet types:

|                  | Multisig Cold | Multisig Hot | MPC Cold | MPC Hot |
| ---------------- | ------------- | ------------ | -------- | ------- |
| **Custody**      | ❌            | ❌           | ✅       | ❌     |
| **Self-Custody** | ❌            | ❌           | ✅       | ✅     |

## Ticker Symbols

| Mainnet | Testnet |
| ------- | ------- |
| vet | tvet |

## Units

The smallest unit of VET (Vechain native coin) is called "Wei".

- 1 VET = `10^18` (1,000,000,000,000,000,000) Wei
- 1 Wei = 0.000000000000000001 VET

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

## Tokens

The Vechain blockchain natively support tokens.

## Fees

Every VET 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.

VET wallets at BitGo utilize a **Gas Tank** to cover transaction fees as the **designated fee payer**. BitGo calculates the total fee based on the `gas_used * gas_unit_price * ( 1 + ( gas_price_coefficient / 255 ))`.

> 📘 **Note:** `gas_price_coefficient` is currently set to `128`. `gas_unit_price` is set to `10,000,000,000,000` wei.

## Create Wallet

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tvet"
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"'",
}'
```
```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('tvet').wallets().generateWallet({
    label: '<DESIRED_WALLET_NAME>',
    passphrase: '<YOUR_BITGO_LOGIN_PASSWORD>',
});

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

# Create Address

Vet does not require a minimum balance for receiving addresses. However, on-chain address initialization incurs an additional cost.

```shell cURL
export COIN="tvet"
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: 'test',
  customRootURI: 'https://app.bitgo-test.com',
});

// Create address
const wallet = await bitgo.coin('tvet').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));
```

## Consolidate Balance

Consolidation Transfer Fee Source: Vechain Gas Tank

To consolidate your receive address balances into the root address, enter the coin as VET, or a VET Token (vet:vtho).

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tvet"
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 = 'tvet';

// 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

Withdrawal Fee Source: Vechain Gas Tank

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tvet"
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/sendmany \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "recipients": [
    {
      "address": "'"$ADDRESS"'",
      "amount": "'"$AMOUNT"'"
    },
  ],
    "walletPassphrase": "'"$WALLET_PASSPHRASE"'"
}'
```
```js JavaScript
let params = {
  recipients: [
    {
      amount: "<AMOUNT",
      address: "<DESTINATION_ADDRESS>",
    },
  ],
  walletPassphrase: "<YOUR_WALLET_PASSPHRASE>",
};
wallet.sendMany(params).then(function (transaction) {
  // Print transaction details
  console.dir(transaction);
});
```

## Stake

BitGo doesn't currently support staking on the Vechain blockchain.
