π‘Using LightSpell API to generate valid XCM calls
To move assets between a parachain to another parachain or directly to the relay chain, we need to sign an extrinsic to create a proper XCM message
"XCM is too complicated"
LightSpell and ParaSpell: the secret ingredients
Asking for a XCM route using ParaSpell API
const xcmApiUrl = "https://api.lightspell.xyz/";
// Construct XCM call from Relay chain to Parachain (DMP)
const dmpResponse = await fetch(
`${xcmApiUrl}/x-transfer?` +
new URLSearchParams({
to: "Moonbeam", // Replace "Moonbeam" with the destination Parachain
amount: 100, // Replace 100 with the amount you wish to transfer (Numeric value)
address: "0x1234" // Replace "0x1234" with the destination wallet address (In AccountID32 or AccountKey20 Format)
})
);
// Construct XCM call from Parachain chain to Relay chain (UMP)
const umpResponse = await fetch(
`${xcmApiUrl}/x-transfer?` +
new URLSearchParams({
from: "Acala", // Replace "Acala" with the sender Parachain
amount: 200, // Replace 200 with the amount you wish to transfer (Numeric value)
address: "0x5678" // Replace "0x5678" with the destination wallet address (In AccountID32 or AccountKey20 Format)
})
);
// Construct XCM call from Parachain to Parachain (HRMP)
const hrmpResponse = await fetch(
`${xcmApiUrl}/x-transfer?` +
new URLSearchParams({
from: "Acala", // Replace "Acala" with the sender Parachain
to: "Moonbeam", // Replace "Moonbeam" with the destination Parachain
currency: "DOT", // Replace "DOT" with asset id or symbol
amount: 300, // Replace 300 with the amount you wish to transfer (Numeric value)
address: "0xABCD" // Replace "0xABCD" with the destination wallet address (In AccountID32 or AccountKey20 Format)
})
);Last updated