Moonbeam XCM SDK Reference: Types and Interfaces
The XCM SDK is based on defining an asset to transfer, then the source chain to send the asset from, and the destination chain to send the asset to, which, together, build the transfer data.
The following sections cover the types and interfaces you'll encounter when working with assets, chains, and transfer data.
Assets
The Asset Object
Defines an asset's key and symbol used on the asset's origin chain.
Attributes
key
string - Identifies an assetoriginSymbol
string - The symbol of the asset on the asset's origin chain
The Asset Amount Object
Defines properties related to an asset, including Asset
properties, the decimals and symbol of the asset, and the amount an associated source or destination address has of the asset.
Note
A few utility methods are available for working with the AssetAmount
class that converts the amount to various formats. Please refer to the Methods for Asset Conversions section.
Attributes
key
string - Identifies an assetoriginSymbol
string - The symbol of the asset on the asset's origin chainamount
bigint - Identifies a particular amount of the asset (i.e., balance, minimum, maximum, etc.)decimals
number - The number of decimals the asset hassymbol
string - The symbol of the asset
Chains
The Ecosystem Type
Specifies the relay chain ecosystem a chain belongs to. Can be any of the following ecosystems as defined by the Ecosystem
enum:
The Chain Type
Specifies what kind of parachain a chain is.
The Chain Asset ID Type
A generic type used to specify the location of the asset on the chain, which is different on every chain.
The Chain Object
Defines properties related to a chain and is used to define the source and destination chains. If a chain is an EVM parachain, there are a couple of additional properties.
Attributes
ecosystem
Ecosystem - Identifies the ecosystem the chain belongs to:polkadot
,kusama
, oralphanet-relay
isTestChain
boolean - Whether the chain is a testnetkey
string - Identifies a chainname
string - The name of the chaintype
ChainType - The type of the chain:parachain
orevm-parachain
assetsData
Map<string, ChainAssetsData> - A list of the assets that the chain supportsgenesisHash
string - The hash of the genesis blockparachainId
number - The ID of the parachain (not the EVM chain ID)ss58Format
number - The ss58 format for the chainusesChainDecimals
boolean - A flag indicating if the chain uses its own decimals in balance queries for all the assets. defaults tofalse
ws
string - The WebSocket endpoint for the chainid
number - For EVM parachains only - The chain IDrpc
string - For EVM parachains only - The HTTP RPC endpoint for the chain
// The Chain object
// Moonbeam's Chain Object
{
ecosystem: 'polkadot',
isTestChain: false,
key: 'moonbeam',
name: 'Moonbeam',
type: 'evm-parachain',
assetsData: [Map],
genesisHash: '0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d',
parachainId: 2004,
ss58Format: 1284,
usesChainDecimals: false,
weight: 1000000000,
ws: 'wss://wss.api.moonbeam.network',
id: 1284,
rpc: 'https://rpc.api.moonbeam.network'
}
The Chain Assets Data Object
Defines the information needed to target the asset on the chain. This is mostly for internal usage to accommodate how chains store their assets. The SDK defaults to the asset ID if certain properties do not apply to the given chain.
Attributes
asset
Asset - The asset's key and origin symbolbalanceId
ChainAssetId - The balance ID of the asset. Defaults to the asset IDdecimals
number - The number of decimals the asset hasid
ChainAssetId - The asset IDmetadataId
ChainAssetId - The metadata ID of the assetminId
ChainAssetId - The minimum ID of the assetpalletInstance
number - The number of the pallet instance the asset belongs tomin
number - The minimum amount of the asset that is required to be left in the account for it to be active. Similar to the existential deposit, except it is for non-native assets
Transfer Data
The Transfer Data Object
Defines the complete transfer data for transferring an asset, including asset, source chain, and destination chain information, as well as a few helper functions for the transfer process.
Attributes
destination
DestinationChainTransferData - The assembled destination chain and address informationgetEstimate
function - Gets the estimated amount of the asset that the destination address will receiveisSwapPossible
boolean - Returns whether or not the swap is possiblemax
AssetAmount - The maximum amount of the asset that can be transferredmin
AssetAmount - The minimum amount of the asset that can be transferredsource
SourceChainTransferData - The assembled source chain and address informationswap
function - Swaps the destination and the source chains and returns the swapped transfer datatransfer
function - Transfers a given amount of the asset from the source chain to the destination chain
// The Transfer Data object
// For sending DOT from Polkadot to Moonbeam
{
destination: {
balance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
chain: {
ecosystem: 'polkadot',
isTestChain: false,
key: 'moonbeam',
name: 'Moonbeam',
type: 'evm-parachain',
assetsData: [Map],
genesisHash: '0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d',
parachainId: 2004,
ss58Format: 1284,
usesChainDecimals: false,
weight: 1000000000,
ws: 'wss://wss.api.moonbeam.network',
id: 1284,
rpc: 'https://rpc.api.moonbeam.network'
},
existentialDeposit: {
key: 'glmr',
originSymbol: 'GLMR',
amount: 0n,
decimals: 18,
symbol: 'GLMR'
},
fee: {
key: 'dot',
originSymbol: 'DOT',
amount: 33068783n,
decimals: 10,
symbol: 'DOT'
},
min: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
}
},
getEstimate: [Function: getEstimate],
isSwapPossible: true,
max: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
min: {
key: 'dot',
originSymbol: 'DOT',
amount: 33068783n,
decimals: 10,
symbol: 'DOT'
},
source: {
balance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
chain: {
ecosystem: 'polkadot',
isTestChain: false,
key: 'polkadot',
name: 'Polkadot',
type: 'parachain',
assetsData: Map(0) {},
genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
parachainId: 0,
ss58Format: 0,
usesChainDecimals: false,
weight: 1000000000,
ws: 'wss://rpc.polkadot.io'
},
destinationFeeBalance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
existentialDeposit: {
key: 'dot',
originSymbol: 'DOT',
amount: 10000000000n,
decimals: 10,
symbol: 'DOT'
},
fee: {
key: 'dot',
originSymbol: 'DOT',
amount: 169328990n,
decimals: 10,
symbol: 'DOT'
},
feeBalance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
max: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
min: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
}
},
swap: [AsyncFunction: swap],
transfer: [AsyncFunction: transfer]
}
The Destination Chain Transfer Data Object
Defines the destination chain data for the transfer.
Attributes
balance
AssetAmount - The balance of the asset being transferred on the destination addresschain
AnyChain - The destination chain informationexistentialDeposit
AssetAmount - The existential deposit for the asset being transferred on the destination chainfee
AssetAmount - The amount of fees for the asset being transferred on the destination chainmin
AssetAmount - The minimum amount of the asset to transfer. This is different thanTransferData.min
, as this dictates the minimum amount that should be received on the destination chain
// The Destination Chain Transfer Data object
// For sending DOT from Polkadot to Moonbeam
{
balance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
chain: {
ecosystem: 'polkadot',
isTestChain: false,
key: 'moonbeam',
name: 'Moonbeam',
type: 'evm-parachain',
assetsData: [Map],
genesisHash: '0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d',
parachainId: 2004,
ss58Format: 1284,
usesChainDecimals: false,
weight: 1000000000,
ws: 'wss://wss.api.moonbeam.network',
id: 1284,
rpc: 'https://rpc.api.moonbeam.network'
},
existentialDeposit: {
key: 'glmr',
originSymbol: 'GLMR',
amount: 0n,
decimals: 18,
symbol: 'GLMR'
},
fee: {
key: 'dot',
originSymbol: 'DOT',
amount: 33068783n,
decimals: 10,
symbol: 'DOT'
},
min: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
}
}
The Source Chain Transfer Data Object
Defines the source chain data for the transfer.
Attributes
balance
AssetAmount - The balance of the asset being transferred for the source addresschain
AnyChain - The source chain informationdestinationFeeBalance
AssetAmount - The balance of the asset used to pay for fees in the destination chainexistentialDeposit
AssetAmount - The existential deposit for the asset being transferred on the source chainfee
AssetAmount - The amount of fees for the asset being transferred on the source chainfeeBalance
AssetAmount - The balance of the asset being transferred on the source chainmin
AssetAmount - The minimum amount of the asset that should be kept on the source chain, taking into consideration theexistentialDeposit
andfee
for the transfermax
AssetAmount - The maximum amount of the asset that can be transferred
// The Source Chain Transfer Data object
// For sending DOT from Polkadot to Moonbeam
{
balance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
chain: {
ecosystem: 'polkadot',
isTestChain: false,
key: 'polkadot',
name: 'Polkadot',
type: 'parachain',
assetsData: Map(0) {},
genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
parachainId: 0,
ss58Format: 0,
usesChainDecimals: false,
weight: 1000000000,
ws: 'wss://rpc.polkadot.io'
},
destinationFeeBalance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
existentialDeposit: {
key: 'dot',
originSymbol: 'DOT',
amount: 10000000000n,
decimals: 10,
symbol: 'DOT'
},
fee: {
key: 'dot',
originSymbol: 'DOT',
amount: 169328990n,
decimals: 10,
symbol: 'DOT'
},
feeBalance: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
max: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
},
min: {
key: 'dot',
originSymbol: 'DOT',
amount: 0n,
decimals: 10,
symbol: 'DOT'
}
}
Signers
The EVM Signer Type
Defines the EVM signer for transfers involving EVM chains. Can be an Ethers signer or viem Wallet Client.
The Polkadot Signer Type
Defines the signer for transfers involving non-EVM chains. Can be a signer or a Keyring pair.