Skip to content

Commit 6c3bbd8

Browse files
brunopgalvaonhussein11Telucero
authored
Add ParaSpell XCM SDK Guide (#898)
* WIP: Creating ParaSpell transfer guide * WIP * Add ParaSpell transfer guide * Update develop/toolkit/interoperability/paraspell/index.md Co-authored-by: Nicolás Hussein <[email protected]> * Update develop/toolkit/interoperability/paraspell/paraspell-xcm-sdk.md Co-authored-by: Nicolás Hussein <[email protected]> * Update develop/toolkit/interoperability/paraspell/paraspell-xcm-sdk.md Co-authored-by: Nicolás Hussein <[email protected]> * Update develop/toolkit/interoperability/paraspell/paraspell-xcm-sdk.md Co-authored-by: Nicolás Hussein <[email protected]> * Update develop/toolkit/interoperability/paraspell/paraspell-xcm-sdk.md Co-authored-by: Nicolás Hussein <[email protected]> * Update content * Update content * Update develop/toolkit/interoperability/paraspell-xcm-sdk/teleport-from-asset-hub-to-relay-chain.md Co-authored-by: Taylor Lucero <[email protected]> * Update develop/toolkit/interoperability/paraspell-xcm-sdk/teleport-from-asset-hub-to-relay-chain.md Co-authored-by: Taylor Lucero <[email protected]> * Update develop/toolkit/interoperability/paraspell-xcm-sdk/teleport-from-asset-hub-to-relay-chain.md Co-authored-by: Taylor Lucero <[email protected]> * Update develop/toolkit/interoperability/paraspell-xcm-sdk/teleport-from-asset-hub-to-relay-chain.md Co-authored-by: Taylor Lucero <[email protected]> * Update develop/toolkit/interoperability/paraspell-xcm-sdk/teleport-from-asset-hub-to-relay-chain.md Co-authored-by: Taylor Lucero <[email protected]> * Update develop/toolkit/interoperability/paraspell-xcm-sdk/index.md Co-authored-by: Taylor Lucero <[email protected]> * Update content * Update content * Update develop/toolkit/interoperability/paraspell-xcm-sdk/teleport-from-asset-hub-to-bridge-hub.md Co-authored-by: Nicolás Hussein <[email protected]> * Update content * llms --------- Co-authored-by: Nicolás Hussein <[email protected]> Co-authored-by: Taylor Lucero <[email protected]>
1 parent 75008c2 commit 6c3bbd8

File tree

12 files changed

+1590
-0
lines changed

12 files changed

+1590
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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: {
14+
parents: 1,
15+
interior: { type: 'X1', value: { type: 'Parachain', value: 1002 } }
16+
}
17+
},
18+
[
19+
{
20+
type: 'V3',
21+
value: [
22+
{
23+
type: 'ReceiveTeleportedAsset',
24+
value: [
25+
{
26+
id: {
27+
type: 'Concrete',
28+
value: {
29+
parents: 1,
30+
interior: { type: 'Here', value: undefined }
31+
}
32+
},
33+
fun: { type: 'Fungible', value: 100000000000n }
34+
}
35+
]
36+
},
37+
{ type: 'ClearOrigin', value: undefined },
38+
{
39+
type: 'BuyExecution',
40+
value: {
41+
fees: {
42+
id: {
43+
type: 'Concrete',
44+
value: {
45+
parents: 1,
46+
interior: { type: 'Here', value: undefined }
47+
}
48+
},
49+
fun: { type: 'Fungible', value: 100000000000n }
50+
},
51+
weight_limit: { type: 'Unlimited', value: undefined }
52+
}
53+
},
54+
{
55+
type: 'DepositAsset',
56+
value: {
57+
assets: {
58+
type: 'Wild',
59+
value: { type: 'AllCounted', value: 1 }
60+
},
61+
beneficiary: {
62+
parents: 0,
63+
interior: {
64+
type: 'X1',
65+
value: {
66+
type: 'AccountId32',
67+
value: {
68+
network: undefined,
69+
id: FixedSizeBinary {
70+
asText: [Function (anonymous)],
71+
asHex: [Function (anonymous)],
72+
asOpaqueHex: [Function (anonymous)],
73+
asBytes: [Function (anonymous)],
74+
asOpaqueBytes: [Function (anonymous)]
75+
}
76+
}
77+
}
78+
}
79+
}
80+
}
81+
},
82+
{
83+
type: 'SetTopic',
84+
value: FixedSizeBinary {
85+
asText: [Function (anonymous)],
86+
asHex: [Function (anonymous)],
87+
asOpaqueHex: [Function (anonymous)],
88+
asBytes: [Function (anonymous)],
89+
asOpaqueBytes: [Function (anonymous)]
90+
}
91+
}
92+
]
93+
}
94+
]
95+
],
96+
destParaId: 1002,
97+
currency: 'PAS'
98+
},
99+
assetHub: undefined,
100+
bridgeHub: undefined,
101+
destination: {
102+
success: true,
103+
fee: 17965000n,
104+
weight: { refTime: 164770000n, proofSize: 3593n },
105+
forwardedXcms: [],
106+
destParaId: undefined,
107+
currency: 'PAS'
108+
},
109+
hops: []
110+
}</span>
111+
</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: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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';
10+
11+
// DOT/PAS has 10 decimals
12+
const PAS_UNITS = 10_000_000_000n;
13+
14+
const SEED_PHRASE =
15+
'INSERT_YOUR_SEED_PHRASE';
16+
17+
// Create Sr25519 signer from mnemonic
18+
function getSigner() {
19+
const entropy = mnemonicToEntropy(SEED_PHRASE);
20+
const miniSecret = entropyToMiniSecret(entropy);
21+
const derive = sr25519CreateDerive(miniSecret);
22+
const keyPair = derive('');
23+
return getPolkadotSigner(keyPair.publicKey, 'Sr25519', keyPair.sign);
24+
}
25+
26+
const RECIPIENT_ADDRESS = ss58Address(getSigner().publicKey);
27+
const SENDER_ADDRESS = ss58Address(getSigner().publicKey);
28+
29+
async function teleport() {
30+
const signer = getSigner();
31+
32+
const tx = await Builder()
33+
.from('AssetHubPaseo')
34+
.to('BridgeHubPaseo')
35+
.currency({
36+
symbol: 'PAS',
37+
amount: 10n * PAS_UNITS, // 10 PAS
38+
})
39+
.address(RECIPIENT_ADDRESS)
40+
.build();
41+
42+
console.log('Built transaction:', inspect(tx, { colors: true, depth: null }));
43+
44+
const result = await tx.signAndSubmit(signer);
45+
console.log(inspect(result, { colors: true, depth: null }));
46+
}
47+
48+
async function dryRunTeleport() {
49+
if (!hasDryRunSupport('AssetHubPaseo')) {
50+
console.log('Dry run is not supported on AssetHubPaseo.');
51+
return;
52+
}
53+
54+
const tx = await Builder()
55+
.from('AssetHubPaseo')
56+
.to('BridgeHubPaseo')
57+
.currency({
58+
symbol: 'PAS',
59+
amount: 10n * PAS_UNITS,
60+
})
61+
.address(RECIPIENT_ADDRESS)
62+
.senderAddress(SENDER_ADDRESS)
63+
.dryRun();
64+
65+
console.log(inspect(tx, { colors: true, depth: null }));
66+
}
67+
68+
dryRunTeleport();
69+
70+
async function verifyED() {
71+
const isValid = await Builder()
72+
.from('AssetHubPaseo')
73+
.to('BridgeHubPaseo')
74+
.currency({
75+
symbol: 'PAS',
76+
amount: 10n * PAS_UNITS,
77+
})
78+
.address(RECIPIENT_ADDRESS)
79+
.senderAddress(SENDER_ADDRESS)
80+
.verifyEdOnDestination();
81+
82+
console.log(`ED verification ${isValid ? 'successful' : 'failed'}.`);
83+
}
84+
85+
verifyED();
86+
87+
async function XcmTransferInfo() {
88+
const info = await Builder()
89+
.from('AssetHubPaseo')
90+
.to('BridgeHubPaseo')
91+
.currency({
92+
symbol: 'PAS',
93+
amount: 10n * PAS_UNITS,
94+
})
95+
.address(RECIPIENT_ADDRESS)
96+
.senderAddress(SENDER_ADDRESS)
97+
.getTransferInfo();
98+
99+
console.log('Transfer Info:', info);
100+
}
101+
102+
XcmTransferInfo();
103+
104+
teleport();

0 commit comments

Comments
 (0)