Installation
Install dependencies
pnpm | npm install || yarn add @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config @polkadot/util
Install SDK
pnpm | npm install || yarn add @paraspell/sdk
Importing package to your project:
Builder pattern:
import { Builder } from '@paraspell/sdk'
Other patterns:
import * as paraspell from '@paraspell/sdk'
const paraspell = require('@paraspell/sdk')
Implementation
NOTES:
- If you wish to transfer from Parachain that uses long IDs for example Moonbeam you have to add the character 'n' the end of currencyID. Eg: .currency(42259045809535163221576417993425387648n) will mean you transfer xcDOT.
- You can now use custom ParachainIDs if you wish to test in TestNet. Just add parachainID as an additional parameter eg: .to('Basilisk', 2948)
- You can now add optional parameter useKeepAlive which will ensure, that you send more than existential deposit.
- Since v5 you can fully customize all multilocations (address, currency and destination). Instead of string parameter simply pass object with multilocation instead for more information refer to the following PR https://github.com/paraspell/xcm-tools/pull/199.
- Fee asset is now an optional parameter.
Builder pattern:
Transfer assets from Parachain to Parachain
await Builder()
.from(NODE)
.to(NODE | Multilocation object )
.currency(CurrencyString| | CurrencyID | Multilocation object)
.amount(amount)
.address(address | Multilocation object )
.build()
Transfer assets from the Relay chain to Parachain
await Builder()
.to(NODE | Multilocation object)
.amount(amount)
.address(address | Multilocation object)
.build()
Transfer assets from Parachain to Relay chain
await Builder()
.from(NODE)
.amount(amount)
.address(address | Multilocation object)
.build()
Use keepAlive option
NOTE: Custom multilocations are not available when keepALive check is used
await Builder()
.from(NODE)
.amount(amount)
.address(address)
.useKeepAlive(destinationParaAPI)
.build()
Close HRMP channels
Builder(api)
.from(NODE)
.closeChannel()
.inbound(inbound)
.outbound(outbound)
.build()
Open HRMP channels
Builder(api)
.from(NODE)
.to(NODE)
.openChannel()
.maxSize(maxSize)
.maxMessageSize(maxMsgSize)
.build()'
Function pattern:
NOTES:
- Since version v5 there was a breaking change introduced. You now pass single object with properties instead of parameters
- Since v5 you can fully customize all multilocations (address, currency and destination). Instead of string parameter simply pass object with multilocation instead for more information refer to the following PR https://github.com/paraspell/xcm-tools/pull/199.
- Custom multilocations are not available when keepALive check is used
await paraspell.xcmPallet.send(
{
api?: ApiPromise,
origin: origin Parachain name string,
currency: CurrencyString | CurrencyID | Multilocation object ,
feeAsset? - Fee asset select id
amount: any,
to: destination address string | Multilocation object,
destination: destination Parachain ID | Multilocation object ,
paraIdTo?: number,
destApiForKeepAlive?: ApiPromise
}
)
await paraspell.xcmPallet.send(
{
api?: ApiPromise,
origin: origin Parachain name string,
amount: any,
feeAsset? - Fee asset select id,
to: destination address string | Multilocation object,
paraIdTo?: number,
destApiForKeepAlive?: ApiPromise
}
)
await paraspell.xcmPallet.transferRelayToPara(
{
api?: ApiPromise,
destination: destination Parachain ID | Multilocation object,
amount: any,
to: destination address string | Multilocation object,
paraIdTo?: number,
destApiForKeepAlive?: ApiPromise
}
)
paraspell.closeChannels.closeChannel(
{
api: ApiPromise,
origin: origin Parachain ID,
inbound: number,
outbound: number
}
)
paraspell.openChannels.openChannel(
{
api: ApiPromise,
origin: origin Parachain ID,
destination: destination Parachain ID,
maxSize: number,
maxMessageSize: number
}
)
Asset queries:
paraspell.assets.getAssetsObject(node: TNode)
paraspell.assets.getAssetId(node: TNode, symbol: string)
paraspell.assets.getRelayChainSymbol(node: TNode)
paraspell.assets.getNativeAssets(node: TNode)
paraspell.assets.getOtherAssets(node: TNode)
paraspell.assets.getAllAssetsSymbols(node: TNode)
paraspell.assets.hasSupportForAsset(node: TNode, symbol: string)
paraspell.assets.getAssetDecimals(node: TNode, symbol: string)
paraspell.assets.getParaId(node: TNode)
paraspell.assets.getTNode(nodeID: number)
paraspell.NODE_NAMES
Parachain XCM Pallet queries
import { getDefaultPallet, getSupportedPallets, SUPPORTED_PALLETS } from '@paraspell/sdk'
getDefaultPallet(node: TNode)
getSupportedPallets(node: TNode)
console.log(SUPPORTED_PALLETS)
Existential deposit queries
import { getExistentialDeposit } from "@paraspell/sdk";
const ed = getExistentialDeposit('Acala')
💻 Tests
-
Run compilation using pnpm compile
-
Run linter using pnpm lint
-
Run unit tests using pnpm test
-
Run end-to-end tests using pnpm test:e2e
-
Update Parachain registered assets in the map using script - pnpm updateAssets
-
Update XCM pallets in the map using script - pnpm updatePallets
-
Update existential deposits in the map using script - pnpm updateEds
-
Run all core tests and checks using pnpm runAll