# Polymesh

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

## Overview

Polymesh (POLYX) is the native asset of the Polymesh blockchain. It targets regulated assets specifically and utilizes:
- Nominated Proof-of-stake (NPoS) model
- Ed25519 signature algorithm

Polymesh focuses on identity, compliance, confidentiality, and governance to enable institutions to securely issue and manage security tokens.

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

## Wallets Types

BitGo enables holding polyx in the following wallet types:

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

## Ticker Symbols

| Mainnet | Testnet |
|---------|---------|
| POLYX   | TPOLYX  |

## Units

The smallest unit for the Polymesh chain is micro POLYX (uPOLYX):
- 1 uPOLYX = 0.000001 POLYX
- 10^6 uPOLYX = 1.000000 POLYX

BitGo recommends using string format to avoid numeric precision issues in balances.

### Native Token

POLYX is the native token of the Polymesh network and is required for paying transaction fees and performing operations on the chain.

### Fees

Polymesh fees are deterministic and vary depending on the type of transaction. They typically consist of:

- A **base fee** associated with each transaction type
- An additional **weight fee** based on execution complexity

Example:

`fee = base_fee + weight_fee`

A small minimum balance of `0.000001 POLYX` is required to initialize accounts.

### Create wallets

```shell cURL
LABEL="My Polymesh Wallet"
PASSPHRASE="secretpassphrasexyz"

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d "{ \"label\": \"$LABEL\", \"passphrase\": \"$PASSPHRASE\", \"multisigType\": \"tss\" }" \
http://$BITGO_EXPRESS_HOST:3080/api/v2/tpolyx/wallet/generate
```
```javascript JavaScript
bitgo
  .coin('tpolyx')
  .wallets()
  .generateWallet({
    label: 'My Polymesh Wallet',
    passphrase: 'secretpassphrasexyz',
    multisigType: 'tss'
  })
  .then(function (wallet) {
    console.dir(wallet);
  });

```

## Estimate Fee

```shell cURL
export COIN="tpolyx"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"

curl -X GET \
 https://app.bitgo-test.com/api/v2/$COIN/tx/fee \
 -H 'Content-Type: application/json' \
 -H "Authorization: Bearer $ACCESS_TOKEN"

```
```js JavaScript
const BitGoJS = require('../../../src/index.js');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
const accessToken = '<YOUR_ACCESS_TOKEN>';
const coin = 'tpolyx';

async function getFeeEstimate() {
  await bitgo.authenticateWithAccessToken({ accessToken });
  const res = await bitgo.coin(coin).feeEstimate({ numBlocks: 2 });
  console.dir(res);
}

getFeeEstimate();

```

## Transact

```shell cURL
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export COIN="tpolyx"
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:3080/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"'"
}'
```
```js JavaScript
const tx = await fundedWallet.send({
    address: `<DESTINATION_ADDRESS>`,
    amount: `<AMOUNT>`,
    walletPassphrase: process.env.PASSWORD as string,
  });
```
