Skip to content

Commit 43eb2de

Browse files
committed
Add ParaSpell transfer guide
1 parent 669758a commit 43eb2de

File tree

10 files changed

+1443
-451
lines changed

10 files changed

+1443
-451
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<div id="termynal" data-termynal>
2+
<span data-ty="input"><span class="file-path"></span>bun run index.ts</span>
3+
<span data-ty>{
4+
failureReason: undefined,
5+
failureChain: undefined,
6+
origin: {
7+
success: true,
8+
fee: 17965000n,
9+
weight: undefined,
10+
forwardedXcms: [
11+
{
12+
type: 'V3',
13+
value: { parents: 1, interior: { type: 'Here', value: undefined } }
14+
},
15+
[
16+
{
17+
type: 'V3',
18+
value: [
19+
{
20+
type: 'ReceiveTeleportedAsset',
21+
value: [
22+
{
23+
id: {
24+
type: 'Concrete',
25+
value: {
26+
parents: 0,
27+
interior: { type: 'Here', value: undefined }
28+
}
29+
},
30+
fun: { type: 'Fungible', value: 100000000000n }
31+
}
32+
]
33+
},
34+
{ type: 'ClearOrigin', value: undefined },
35+
{
36+
type: 'BuyExecution',
37+
value: {
38+
fees: {
39+
id: {
40+
type: 'Concrete',
41+
value: {
42+
parents: 0,
43+
interior: { type: 'Here', value: undefined }
44+
}
45+
},
46+
fun: { type: 'Fungible', value: 100000000000n }
47+
},
48+
weight_limit: { type: 'Unlimited', value: undefined }
49+
}
50+
},
51+
{
52+
type: 'DepositAsset',
53+
value: {
54+
assets: {
55+
type: 'Wild',
56+
value: { type: 'AllCounted', value: 1 }
57+
},
58+
beneficiary: {
59+
parents: 0,
60+
interior: {
61+
type: 'X1',
62+
value: {
63+
type: 'AccountId32',
64+
value: {
65+
network: undefined,
66+
id: FixedSizeBinary {
67+
asText: [Function (anonymous)],
68+
asHex: [Function (anonymous)],
69+
asOpaqueHex: [Function (anonymous)],
70+
asBytes: [Function (anonymous)],
71+
asOpaqueBytes: [Function (anonymous)]
72+
}
73+
}
74+
}
75+
}
76+
}
77+
}
78+
},
79+
{
80+
type: 'SetTopic',
81+
value: FixedSizeBinary {
82+
asText: [Function (anonymous)],
83+
asHex: [Function (anonymous)],
84+
asOpaqueHex: [Function (anonymous)],
85+
asBytes: [Function (anonymous)],
86+
asOpaqueBytes: [Function (anonymous)]
87+
}
88+
}
89+
]
90+
}
91+
]
92+
],
93+
destParaId: 0,
94+
currency: 'PAS'
95+
},
96+
assetHub: undefined,
97+
bridgeHub: undefined,
98+
destination: {
99+
success: true,
100+
fee: 22511801n,
101+
weight: { refTime: 283750000n, proofSize: 7186n },
102+
forwardedXcms: [],
103+
destParaId: undefined,
104+
currency: 'PAS'
105+
},
106+
hops: []
107+
}</span>
108+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div id="termynal" data-termynal>
2+
<span data-ty="input"><span class="file-path"></span>bun run index.ts</span>
3+
<span data-ty>...</span>
4+
<span data-ty>ED verification successful.</span>
5+
</div>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import { Builder, hasDryRunSupport } from '@paraspell/sdk';
2+
import {
3+
entropyToMiniSecret,
4+
mnemonicToEntropy,
5+
ss58Address,
6+
} from '@polkadot-labs/hdkd-helpers';
7+
import { getPolkadotSigner } from 'polkadot-api/signer';
8+
import { sr25519CreateDerive } from '@polkadot-labs/hdkd';
9+
import { inspect } from 'util'; // Used for debugging
10+
11+
// DOT/PAS has 10 decimals
12+
const PAS_UNITS = 10_000_000_000n;
13+
14+
// Replace with your own mnemonic
15+
const SEED_PHRASE =
16+
'depart thank scorpion shed dutch code above pledge insect recycle giraffe salt';
17+
18+
// Create Sr25519 signer from mnemonic
19+
function getSigner() {
20+
const entropy = mnemonicToEntropy(SEED_PHRASE);
21+
const miniSecret = entropyToMiniSecret(entropy);
22+
const derive = sr25519CreateDerive(miniSecret);
23+
const keyPair = derive('');
24+
return getPolkadotSigner(keyPair.publicKey, 'Sr25519', keyPair.sign);
25+
}
26+
27+
const RECIPIENT_ADDRESS = ss58Address(getSigner().publicKey);
28+
const SENDER_ADDRESS = ss58Address(getSigner().publicKey);
29+
30+
async function teleport() {
31+
const signer = getSigner();
32+
33+
const tx = await Builder()
34+
.from('AssetHubPaseo')
35+
.to('Paseo')
36+
.currency({
37+
symbol: 'PAS',
38+
amount: 10n * PAS_UNITS, // 10 PAS
39+
})
40+
.address(RECIPIENT_ADDRESS)
41+
.build();
42+
43+
console.log('Built transaction:', inspect(tx, { colors: true, depth: null }));
44+
45+
const result = await tx.signAndSubmit(signer);
46+
console.log(inspect(result, { colors: true, depth: null }));
47+
}
48+
49+
async function dryRunTeleport() {
50+
if (!hasDryRunSupport('AssetHubPaseo')) {
51+
console.log('Dry run is not supported on AssetHubPaseo.');
52+
return;
53+
}
54+
55+
const tx = await Builder()
56+
.from('AssetHubPaseo')
57+
.to('Paseo')
58+
.currency({
59+
symbol: 'PAS',
60+
amount: 10n * PAS_UNITS,
61+
})
62+
.address(RECIPIENT_ADDRESS)
63+
.senderAddress(SENDER_ADDRESS)
64+
.dryRun();
65+
66+
console.log(inspect(tx, { colors: true, depth: null }));
67+
}
68+
69+
dryRunTeleport();
70+
71+
async function verifyED() {
72+
const isValid = await Builder()
73+
.from('AssetHubPaseo')
74+
.to('Paseo')
75+
.currency({
76+
symbol: 'PAS',
77+
amount: 10n * PAS_UNITS,
78+
})
79+
.address(RECIPIENT_ADDRESS)
80+
.senderAddress(SENDER_ADDRESS)
81+
.verifyEdOnDestination();
82+
83+
console.log(`ED verification ${isValid ? 'successful' : 'failed'}.`);
84+
}
85+
86+
verifyED();
87+
88+
async function XcmTransferInfo() {
89+
const info = await Builder()
90+
.from('AssetHubPaseo')
91+
.to('Paseo')
92+
.currency({
93+
symbol: 'PAS',
94+
amount: 10n * PAS_UNITS,
95+
})
96+
.address(RECIPIENT_ADDRESS)
97+
.senderAddress(SENDER_ADDRESS)
98+
.getTransferInfo();
99+
100+
console.log('Transfer Info:', info);
101+
}
102+
103+
XcmTransferInfo();
104+
105+
teleport();

0 commit comments

Comments
 (0)