Last active
June 29, 2024 17:09
-
-
Save sinzii/078a48976827e3a85f5cebda0930d1f9 to your computer and use it in GitHub Desktop.
Teleport WND from Westend Asset Hub to Westend via XCM with `dedot`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DedotClient } from 'dedot'; | |
import { WestendAssetHubApi, XcmVersionedLocation, XcmVersionedAssets, XcmV3WeightLimit } from '@dedot/chaintypes/westendAssetHub'; | |
import { AccountId32 } from 'dedot/codecs'; | |
const TWO_TOKENS = 2_000_000_000_000n; | |
const destAddress = <bobAddress>; | |
const api = await DedotClient.new<WestendAssetHubApi>('...westend-assethub-rpc...'); | |
const dest: XcmVersionedLocation = { | |
type: 'V3', | |
value: { parents: 1, interior: { type: 'Here' } }, | |
}; | |
const beneficiary: XcmVersionedLocation = { | |
type: 'V3', | |
value: { | |
parents: 0, | |
interior: { | |
type: 'X1', | |
value: { | |
type: 'AccountId32', | |
value: { id: new AccountId32(destAddress).raw }, | |
}, | |
}, | |
}, | |
}; | |
const assets: XcmVersionedAssets = { | |
type: 'V3', | |
value: [ | |
{ | |
id: { | |
type: 'Concrete', | |
value: { | |
parents: 1, | |
interior: { type: 'Here' }, | |
}, | |
}, | |
fun: { | |
type: 'Fungible', | |
value: TWO_TOKENS, | |
}, | |
}, | |
], | |
}; | |
const weight: XcmV3WeightLimit = { type: 'Unlimited' }; | |
api.tx.polkadotXcm | |
.limitedTeleportAssets(dest, beneficiary, assets, 0, weight) | |
.signAndSend(alice, { signer, tip: 1_000_000n }, (result) => { | |
console.dir(result, { depth: null }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment