Skip to content

Asset πŸ’° query operations for your front-end ​

This functionality serves to retrieve asset data from compatible Parachains. Users can retrieve details like asset decimals, registered assets on particular Parachain, check if the asset is registered on Parachain and more.

Import functionality ​

To use this functionality you first have to import it in the following way.

ts
//PAPI
import { getSupportedAssets, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTNode, getAssetMultiLocation, NODE_NAMES } from  '@paraspell/sdk'
//PJS
import { getSupportedAssets, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTNode, getAssetMultiLocation, NODE_NAMES } from  '@paraspell/sdk-pjs'
ts
//Standalone asset package
yarn add || pnpm | npm install @paraspell/assets

import { getSupportedAssets, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTNode, getAssetMultiLocation, NODE_NAMES } from  '@paraspell/assets'

Query assets supported between chains ​

Following query lets you query assets supported between two selected Parachains.

ts
getSupportedAssets(ORIGIN_NODE, DESTINATION_NODE)

Example output:

json
[
   {
      "symbol":"DOT",
      "isNative":true,
      "decimals":10,
      "multiLocation":{
         "parents":1,
         "interior":{
            "Here":null
         }
      },
      "existentialDeposit":"100000000"
   },
   {
      "assetId":"1337",
      "symbol":"USDC",
      "decimals":6,
      "multiLocation":{
         "parents":1,
         "interior":{
            "X3":[
               {
                  "Parachain":1000
               },
               {
                  "PalletInstance":50
               },
               {
                  "GeneralIndex":1337
               }
            ]
         }
      },
      "existentialDeposit":"10000"
   },
   {
      "assetId":"1984",
      "symbol":"USDt",
      "decimals":6,
      "multiLocation":{
         "parents":1,
         "interior":{
            "X3":[
               {
                  "Parachain":1000
               },
               {
                  "PalletInstance":50
               },
               {
                  "GeneralIndex":1984
               }
            ]
         }
      },
      "existentialDeposit":"10000"
   },
   {
      "symbol":"PLMC",
      "decimals":10,
      "multiLocation":{
         "parents":1,
         "interior":{
            "X1":[
               {
                  "Parachain":3344
               }
            ]
         }
      },
      "existentialDeposit":"1000000000"
   },
   {
      "symbol":"USDC",
      "decimals":6,
      "multiLocation":{
         "parents":2,
         "interior":{
            "X2":[
               {
                  "GlobalConsensus":{
                     "Ethereum":{
                        "chainId":1
                     }
                  }
               },
               {
                  "AccountKey20":{
                     "network":null,
                     "key":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
                  }
               }
            ]
         }
      },
      "existentialDeposit":"10000",
      "isFeeAsset":true
   },
   {
      "symbol":"USDT",
      "decimals":6,
      "multiLocation":{
         "parents":2,
         "interior":{
            "X2":[
               {
                  "GlobalConsensus":{
                     "Ethereum":{
                        "chainId":1
                     }
                  }
               },
               {
                  "AccountKey20":{
                     "network":null,
                     "key":"0xdac17f958d2ee523a2206206994597c13d831ec7"
                  }
               }
            ]
         }
      },
      "existentialDeposit":"10000",
      "isFeeAsset":true
   }
]

Query fee assets ​

This function returns assets object from assets.json for particular Parachain for assets that have feeAsset property.

ts
getFeeAssets(NODE)

Example output:

json
[
  {
    "isNative": true,
    "symbol": "ACA",
    "decimals": 12,
    "existentialDeposit": "100000000000",
    "multiLocation": {
      "parents": 1,
      "interior": {
        "X2": [
          {
            "Parachain": 2000
          },
          {
            "GeneralKey": {
              "length": 2,
              "data": "0x0000000000000000000000000000000000000000000000000000000000000000"
            }
          }
        ]
      }
    }
  }
]

Convert id or symbol to multilocation ​

Get multilocation for asset id or symbol.

ts
getAssetMultiLocation(NODE, { symbol: symbol } | { id: assetId })

Example output:

json
{
  "parents": 1,
  "interior": {
    "Here": null
  }
}

Query assets object ​

This function returns assets object from assets.json for particular Parachain including information about native and foreign assets.

ts
getAssetsObject(NODE)

Example output:

json
{
  "relayChainAssetSymbol": "DOT",
  "nativeAssetSymbol": "AJUN",
  "isEVM": false,
  "ss58Prefix": 1328,
  "supportsDryRunApi": false,
  "supportsXcmPaymentApi": false,
  "nativeAssets": [
    {
      "symbol": "AJUN",
      "isNative": true,
      "decimals": 12,
      "existentialDeposit": "1000000000"
    }
  ],
  "otherAssets": [
    {
      "assetId": "0",
      "symbol": "DOT",
      "decimals": 10,
      "existentialDeposit": "1000000000",
      "multiLocation": {
        "parents": 1,
        "interior": {
          "Here": null
        }
      }
    },
    {
      "assetId": "847713",
      "symbol": "DMOG",
      "decimals": 12,
      "existentialDeposit": "10000000000"
    },
    {
      "assetId": "1984",
      "symbol": "USDt",
      "decimals": 6,
      "existentialDeposit": "10000",
      "multiLocation": {
        "parents": 1,
        "interior": {
          "X3": [
            {
              "Parachain": 1000
            },
            {
              "PalletInstance": 50
            },
            {
              "GeneralIndex": 1984
            }
          ]
        }
      }
    },
    {
      "assetId": "1337",
      "symbol": "USDC",
      "decimals": 6,
      "existentialDeposit": "10000",
      "multiLocation": {
        "parents": 1,
        "interior": {
          "X3": [
            {
              "Parachain": 1000
            },
            {
              "PalletInstance": 50
            },
            {
              "GeneralIndex": 1337
            }
          ]
        }
      }
    }
  ]
}

Query asset ID ​

This function returns assetId for particular Parachain and asset symbol

ts
getAssetId(NODE, ASSET_SYMBOL)

Example output:

json
"340282366920938463463374607431768211455"

Query Relay chain asset symbol ​

This function returns the symbol of the Relay chain for a particular Parachain. Either "DOT" or "KSM"

ts
getRelayChainSymbol(NODE)

Example output:

json
"DOT"

Query native assets ​

This function returns a string array of native assets symbols for a particular Parachain

ts
getNativeAssets(NODE)

Example output:

json
[
  {
    "symbol": "ASTR",
    "isNative": true,
    "decimals": 18,
    "existentialDeposit": "1000000",
    "multiLocation": {
      "parents": 1,
      "interior": {
        "X1": {
          "Parachain": 2006
        }
      }
    }
  }
]

Query foreign assets ​

This function returns an object array of foreign assets for a particular Parachain. Each object has a symbol and assetId property

ts
getOtherAssets(NODE)

Example output:

json
[
  {
    "assetId": "1029",
    "symbol": "DOT",
    "decimals": 10,
    "multiLocation": {
      "parents": 1,
      "interior": {
        "Here": null
      }
    },
    "existentialDeposit": "1",
    "isFeeAsset": true
  },
  {
    "assetId": "1027",
    "symbol": "ahUSDT",
    "decimals": 6,
    "multiLocation": {
      "parents": 1,
      "interior": {
        "X3": [
          {
            "Parachain": 1000
          },
          {
            "PalletInstance": 50
          },
          {
            "GeneralIndex": 1984
          }
        ]
      }
    },
    "existentialDeposit": "1",
    "isFeeAsset": true
  },
  {
    "assetId": "1028",
    "symbol": "ahPINK",
    "decimals": 10,
    "multiLocation": {
      "parents": 1,
      "interior": {
        "X3": [
          {
            "Parachain": 1000
          },
          {
            "PalletInstance": 50
          },
          {
            "GeneralIndex": 23
          }
        ]
      }
    },
    "existentialDeposit": "1"
  }
]

Query all asset symbols ​

Function returns string array of all asset symbols for a specific Parachain. (native and foreign assets are merged into a single array)

ts
getAllAssetsSymbols(NODE)

Example output:

json
[
  "BNC",
  "vBNC",
  "IBTC",
  "MANTA",
  "WETH",
  "DOT",
  "USDT",
  "USDC",
  "DED",
  "PINK",
  "GLMR",
  "vGLMR",
  "BNCS",
  "vMANTA",
  "PEN",
  "vASTR",
  "vDOT",
  "INTR",
  "ETH",
  "vFIL",
  "FIL",
  "ASTR",
  "vsDOT"
]

Query asset support ​

The function checks if Parachain supports a particular asset. (Both native and foreign assets are searched). Returns boolean

ts
hasSupportForAsset(NODE, ASSET_SYMBOL)

Example output:

json
true

Query asset decimals ​

The function returns decimals for a specific asset

ts
getAssetDecimals(NODE, ASSET_SYMBOL)

Example output:

json
12

Query Parachain ID ​

The function returns specific Parachain id

ts
getParaId(NODE)

Example output:

json
2000

Query Parachain name ​

Function to get specific TNode from Parachain id

ts
getTNode(paraID: number, ecosystem: 'polkadot' || 'kusama' || 'ethereum') //When Ethereum ecosystem is selected please fill nodeID as 1 to select Ethereum.

Example output:

json
"Astar"

Import Parachains as constant ​

Import all compatible Parachains as constant

ts
console.log(NODE_NAMES)