Skip to content

Instantly share code, notes, and snippets.

@sinzii
Last active June 29, 2024 17:09
Show Gist options
  • Save sinzii/078a48976827e3a85f5cebda0930d1f9 to your computer and use it in GitHub Desktop.
Save sinzii/078a48976827e3a85f5cebda0930d1f9 to your computer and use it in GitHub Desktop.
Teleport WND from Westend Asset Hub to Westend via XCM with `dedot`
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