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.
//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'
//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.
getSupportedAssets(ORIGIN_NODE, DESTINATION_NODE)
Example output:
[
{
"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.
getFeeAssets(NODE)
Example output:
[
{
"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.
getAssetMultiLocation(NODE, { symbol: symbol } | { id: assetId })
Example output:
{
"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.
getAssetsObject(NODE)
Example output:
{
"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
getAssetId(NODE, ASSET_SYMBOL)
Example output:
"340282366920938463463374607431768211455"
Query Relay chain asset symbol β
This function returns the symbol
of the Relay chain for a particular Parachain. Either "DOT" or "KSM"
getRelayChainSymbol(NODE)
Example output:
"DOT"
Query native assets β
This function returns a string array of native
assets symbols for a particular Parachain
getNativeAssets(NODE)
Example output:
[
{
"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
getOtherAssets(NODE)
Example output:
[
{
"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)
getAllAssetsSymbols(NODE)
Example output:
[
"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
hasSupportForAsset(NODE, ASSET_SYMBOL)
Example output:
true
Query asset decimals β
The function returns decimals for a specific asset
getAssetDecimals(NODE, ASSET_SYMBOL)
Example output:
12
Query Parachain ID β
The function returns specific Parachain id
getParaId(NODE)
Example output:
2000
Query Parachain name β
Function to get specific TNode from Parachain id
getTNode(paraID: number, ecosystem: 'polkadot' || 'kusama' || 'ethereum') //When Ethereum ecosystem is selected please fill nodeID as 1 to select Ethereum.
Example output:
"Astar"
Import Parachains as constant β
Import all compatible Parachains as constant
console.log(NODE_NAMES)