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 { getSupportedDestinations, getSupportedAssets, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, TParachain, TRelaychain, TSubstrateChain, TExternalChain, TChain, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk'
//PJS
import { getSupportedDestinations, getSupportedAssets, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, TParachain, TRelaychain, TSubstrateChain, TExternalChain, TChain, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk-pjs'//Standalone asset package
yarn add || pnpm | npm install @paraspell/assets
import { getSupportedDestinations, getSupportedAssets, getFeeAssets, getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTChain, getAssetLocation, TParachain, TRelaychain, TSubstrateChain, TExternalChain, TChain, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/assets'Query asset paths β
Following query lets you query paths that should be supported for specific asset related to origin chain.
getSupportedDestinations(CHAIN, CURRENCY)Example output:
[
"Acala",
"BifrostPolkadot",
"ComposableFinance",
"Hydration",
"Moonbeam",
"Pendulum",
"Phala"
]Query assets supported between chains β
Following query lets you query assets supported between two selected Parachains.
getSupportedAssets(ORIGIN_CHAIN, DESTINATION_CHAIN)Example output:
An example of output for AssetHubPolkadot and Polimec as input
[
{
"symbol":"DOT",
"isNative":true,
"decimals":10,
"location":{
"parents":1,
"interior":{
"Here":null
}
},
"existentialDeposit":"100000000"
},
{
"assetId":"1337",
"symbol":"USDC",
"decimals":6,
"location":{
"parents":1,
"interior":{
"X3":[
{
"Parachain":1000
},
{
"PalletInstance":50
},
{
"GeneralIndex":1337
}
]
}
},
"existentialDeposit":"10000"
},
{
"assetId":"1984",
"symbol":"USDt",
"decimals":6,
"location":{
"parents":1,
"interior":{
"X3":[
{
"Parachain":1000
},
{
"PalletInstance":50
},
{
"GeneralIndex":1984
}
]
}
},
"existentialDeposit":"10000"
},
{
"symbol":"PLMC",
"decimals":10,
"location":{
"parents":1,
"interior":{
"X1":[
{
"Parachain":3344
}
]
}
},
"existentialDeposit":"1000000000"
},
{
"symbol":"USDC",
"decimals":6,
"location":{
"parents":2,
"interior":{
"X2":[
{
"GlobalConsensus":{
"Ethereum":{
"chainId":1
}
}
},
{
"AccountKey20":{
"network":null,
"key":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
}
}
]
}
},
"existentialDeposit":"10000",
"isFeeAsset":true
},
{
"symbol":"USDT",
"decimals":6,
"location":{
"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(CHAIN)Example output:
[
{
"isNative": true,
"symbol": "ACA",
"decimals": 12,
"existentialDeposit": "100000000000",
"location": {
"parents": 1,
"interior": {
"X2": [
{
"Parachain": 2000
},
{
"GeneralKey": {
"length": 2,
"data": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
]
}
}
}
]Convert id or symbol to location β
Get location for asset id or symbol.
getAssetLocation(CHAIN, { 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(CHAIN)Example output:
An example of output for Ajuna as input
{
"relaychainSymbol": "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",
"location": {
"parents": 1,
"interior": {
"Here": null
}
}
},
{
"assetId": "847713",
"symbol": "DMOG",
"decimals": 12,
"existentialDeposit": "10000000000"
},
{
"assetId": "1984",
"symbol": "USDt",
"decimals": 6,
"existentialDeposit": "10000",
"location": {
"parents": 1,
"interior": {
"X3": [
{
"Parachain": 1000
},
{
"PalletInstance": 50
},
{
"GeneralIndex": 1984
}
]
}
}
},
{
"assetId": "1337",
"symbol": "USDC",
"decimals": 6,
"existentialDeposit": "10000",
"location": {
"parents": 1,
"interior": {
"X3": [
{
"Parachain": 1000
},
{
"PalletInstance": 50
},
{
"GeneralIndex": 1337
}
]
}
}
}
]
}Query asset ID β
This function returns assetId for particular Parachain and asset symbol
getAssetId(CHAIN, 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(CHAIN)Example output:
"DOT"Query native assets β
This function returns a string array of native assets symbols for a particular Parachain
getNativeAssets(CHAIN)Example output:
[
{
"symbol": "ASTR",
"isNative": true,
"decimals": 18,
"existentialDeposit": "1000000",
"location": {
"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(CHAIN)Example output:
An example of output for Darwinia as input
[
{
"assetId": "1029",
"symbol": "DOT",
"decimals": 10,
"location": {
"parents": 1,
"interior": {
"Here": null
}
},
"existentialDeposit": "1",
"isFeeAsset": true
},
{
"assetId": "1027",
"symbol": "ahUSDT",
"decimals": 6,
"location": {
"parents": 1,
"interior": {
"X3": [
{
"Parachain": 1000
},
{
"PalletInstance": 50
},
{
"GeneralIndex": 1984
}
]
}
},
"existentialDeposit": "1",
"isFeeAsset": true
},
{
"assetId": "1028",
"symbol": "ahPINK",
"decimals": 10,
"location": {
"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(CHAIN)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 I β
The function checks if Parachain supports a particular asset. (Both native and foreign assets are searched). Returns boolean.
hasSupportForAsset(CHAIN, ASSET_SYMBOL)Example output:
trueQuery asset support II β
The function checks if Parachain supports a particular asset. Returns asset object or null. Destination parameter is optional and should be set to Ethereum when using snowbridge assets.
findAssetInfo(CHAIN, CURRENCY, DESTINATION?)Example output:
{
"assetId": "1000771",
"symbol": "KSM",
"decimals": 12,
"existentialDeposit": "313283208",
"location": {
"parents": 2,
"interior": {
"X1": [
{
"GlobalConsensus": {
"kusama": null
}
}
]
}
},
"isFeeAsset": true
}Query asset support III β
The function checks if Parachain supports a particular asset. Returns asset object or error. Destination parameter is optional and should be set to Ethereum when using snowbridge assets.
findAssetInfoOrThrow(CHAIN, CURRENCY, DESTINATION?)Example output:
{
"assetId": "1000771",
"symbol": "KSM",
"decimals": 12,
"existentialDeposit": "313283208",
"location": {
"parents": 2,
"interior": {
"X1": [
{
"GlobalConsensus": {
"kusama": null
}
}
]
}
},
"isFeeAsset": true
}Query asset decimals β
The function returns decimals for a specific asset
getAssetDecimals(CHAIN, ASSET_SYMBOL)Example output:
12Query Parachain ID β
The function returns specific Parachain id
getParaId(CHAIN)Example output:
2000Query Parachain name β
Function to get specific TChain from Parachain id
getTChain(paraID: number, ecosystem: 'Polkadot' | 'Kusama' | 'Passeo' | 'Westend' | 'Ethereum') // When Ethereum ecosystem is selected please fill CHAINID as 1 to select Ethereum.Example output:
"Astar"Import Chains as types β
There are 5 options for types you can choose based on your prefference
// Export all Parachains
console.log(TParachain)
// Export all Relay chains
console.log(TRelaychain)
// Export all Substrate chains (Parachains + Relays)
console.log(TSubstrateChain)
// Export chains outside Polkadot ecosystem (Ethereum)
console.log(TExternalChain)
// Export all chains implemented in ParaSpell
console.log(TChain)Import Chains as constants β
There are 5 options for constants you can choose based on your prefference
// Export all Parachains
console.log(PARACHAINS)
// Export all Relay chains
console.log(RELAYCHAINS)
// Export all Substrate chains (Parachains + Relays)
console.log(SUBSTRATE_CHAINS)
// Export chains outside Polkadot ecosystem (Ethereum)
console.log(EXTERNAL_CHAINS)
// Export all chains implemented in ParaSpell
console.log(CHAINS)