Skip to content

Commit 29a5c51

Browse files
committed
refactored according to feedback
1 parent 2b595bd commit 29a5c51

File tree

6 files changed

+122
-100
lines changed

6 files changed

+122
-100
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div id="termynal" data-termynal>
2+
<span data-ty> Send via PAPI console:</span>
3+
<span data-ty> https://dev.papi.how/extrinsics#networkId=paseo_asset_hub&endpoint=light-client&data=0x1c041c...</span>
4+
</div>

develop/interoperability/best-practices-for-teleporting-assets.md

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ You can refer to the following snippets to check for the Existential Deposit (ED
9191

9292
=== "PolkadotJS API"
9393
```javascript
94+
const { ApiPromise, WsProvider } = require('@polkadot/api');
95+
const provider = new WsProvider('wss://rpc.polkadot.io');
96+
const api = await ApiPromise.create({ provider });
97+
9498
async function checkAccountExistence(api, address) {
9599
const accountInfo = await api.query.system.account(address);
96100
const balance = accountInfo.data.free.toBigInt();
@@ -140,6 +144,7 @@ For non-sufficient assets, make sure the destination account has enough native t
140144
Use proper runtime APIs for accurate fee estimation rather than hardcoded values:
141145

142146
- [Transaction Payment API](https://paritytech.github.io/polkadot-sdk/master/pallet_transaction_payment_rpc/trait.TransactionPaymentRuntimeApi.html){target=\_blank} for local fees:
147+
143148
```typescript
144149
import { dot } from "@polkadot-api/descriptors";
145150
import { createClient } from "polkadot-api";
@@ -153,8 +158,10 @@ Use proper runtime APIs for accurate fee estimation rather than hardcoded values
153158
call.encodedLength
154159
);
155160
```
161+
This code establishes a connection to the Polkadot network and queries detailed fee information for a specific transaction call, including base fees, length fees, and tip calculations.
156162

157163
- [XCM Payment API](https://paritytech.github.io/polkadot-sdk/master/xcm_runtime_apis/fees/trait.XcmPaymentApi.html){target=\_blank} for cross-chain delivery fees:
164+
158165
```typescript
159166
import { dot } from "@polkadot-api/descriptors";
160167
import { createClient } from "polkadot-api";
@@ -168,14 +175,16 @@ Use proper runtime APIs for accurate fee estimation rather than hardcoded values
168175
message
169176
);
170177
```
178+
This code calculates the delivery fees required to send an XCM message to a specific destination parachain, helping estimate cross-chain transaction costs.
171179

172180
- [Asset Conversion API](https://paritytech.github.io/polkadot-sdk/master/pallet_asset_conversion/trait.AssetConversionApi.html){target=\_blank} (available on Asset Hub) for fee conversion:
181+
173182
```typescript
174183
import { ah } from "@polkadot-api/descriptors";
175184
import { createClient } from "polkadot-api";
176185
import { getWsProvider } from "polkadot-api/ws-provider/web";
177186

178-
const client = createClient(getWsProvider("wss://rpc.polkadot.io"));
187+
const client = createClient(getWsProvider("wss://asset-hub-paseo.dotters.network"));
179188
const api = client.getTypedApi(ah);
180189

181190
const feeInAsset = await api.apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(
@@ -184,6 +193,7 @@ Use proper runtime APIs for accurate fee estimation rather than hardcoded values
184193
amountIn
185194
);
186195
```
196+
This code connects to Asset Hub's `AssetConversionApi` and calculates the exchange rate between different assets, allowing users to determine how much of one token they need to pay fees in another token.
187197

188198
### Multi-Asset Fee Handling
189199

@@ -195,17 +205,17 @@ For dealing with non-sufficient assets and fees, there are different fee payment
195205

196206
## Asset Type Considerations
197207

198-
| **Sufficient Assets** | **Non-Sufficient Assets** |
199-
|-------------------------------------------------------------|-----------------------------------------------------------------|
200-
| **Capabilities:** | **Requirements:** |
201-
| Pay for transaction fees directly |Existing destination accounts with ED |
202-
| Meet existential deposit requirements | • Alternative fee payment mechanisms |
203-
| Can suffice for creating new accounts | |
204-
| | |
205-
| **Best Practices:** | **Best Practices:** |
206-
| Verify minimum transfer amounts meet destination requirements |Always verify recipient account status |
207-
| Account for both transaction and existential deposit costs |Include asset conversion for ED if needed |
208-
| Handle automatic account creation scenarios | Plan for fee payment using sufficient assets |
208+
| **Sufficient Assets** | **Non-Sufficient Assets** |
209+
| :-------------------------------------------------------------------------: | :-----------------------------------------------------------------------------: |
210+
| **Capabilities** | **Requirements** |
211+
| Pay for transaction fees directly | Existing destination accounts with ED |
212+
| Meet existential deposit requirements | Alternative fee payment mechanisms |
213+
| Can suffice for creating new accounts | |
214+
| | |
215+
| **Best Practices** | **Best Practices** |
216+
| Verify minimum transfer amounts meet destination requirements | Always verify recipient account status |
217+
| Account for both transaction and existential deposit costs | Include asset conversion for ED if needed |
218+
| Handle automatic account creation scenarios | Plan for fee payment using sufficient assets |
209219

210220
!!!note Sufficient Assets
211221
Always check the chain to see what assets are considered sufficient assets.
@@ -237,14 +247,14 @@ Asset teleportation failures can occur for various reasons, each with specific c
237247
**[FailedToTransactAsset](https://paritytech.github.io/polkadot-sdk/master/cumulus_primitives_core/enum.XcmError.html#variant.FailedToTransactAsset) Errors**
238248

239249
- **Common Causes:**
240-
- Missing destination accounts
241-
- Insufficient existential deposits
242-
- Asset not found on destination
250+
- Missing destination accounts
251+
- Insufficient existential deposits
252+
- Asset not found on destination
243253

244254
- **Prevention:**
245-
- Verify account existence before transfer
246-
- Ensure existential deposit (ED) requirements are met
247-
- Validate asset registration on the destination chain
255+
- Verify account existence before transfer
256+
- Ensure existential deposit (ED) requirements are met
257+
- Validate asset registration on the destination chain
248258

249259
---
250260

@@ -253,14 +263,14 @@ Asset teleportation failures can occur for various reasons, each with specific c
253263
**[TooExpensive](https://paritytech.github.io/polkadot-sdk/master/cumulus_primitives_core/enum.XcmError.html#variant.TooExpensive) Errors**
254264

255265
- **Common Causes:**
256-
- Insufficient funds for fees
257-
- Fee payment asset not accepted
258-
- High network congestion costs
266+
- Insufficient funds for fees
267+
- Fee payment asset not accepted
268+
- High network congestion costs
259269

260270
- **Prevention:**
261-
- Implement proper fee estimation
262-
- Include a buffer for fee fluctuations
263-
- Use asset conversion when necessary
271+
- Implement proper fee estimation
272+
- Include a buffer for fee fluctuations
273+
- Use asset conversion when necessary
264274

265275
---
266276

@@ -269,14 +279,14 @@ Asset teleportation failures can occur for various reasons, each with specific c
269279
**[AssetNotFound](https://paritytech.github.io/polkadot-sdk/master/cumulus_primitives_core/enum.XcmError.html#variant.AssetNotFound) Errors**
270280

271281
- **Common Causes:**
272-
- Asset not registered on the destination
273-
- Incorrect asset ID or format
274-
- Asset not enabled for XCM
282+
- Asset not registered on the destination
283+
- Incorrect asset ID or format
284+
- Asset not enabled for XCM
275285

276286
- **Prevention:**
277-
- Verify asset registration before transfer
278-
- Use correct asset identifiers
279-
- Check XCM configuration for asset support
287+
- Verify asset registration before transfer
288+
- Use correct asset identifiers
289+
- Check XCM configuration for asset support
280290

281291
---
282292

@@ -285,16 +295,16 @@ Asset teleportation failures can occur for various reasons, each with specific c
285295
**[Barrier](https://paritytech.github.io/polkadot-sdk/master/cumulus_primitives_core/enum.XcmError.html#variant.Barrier) Errors**
286296

287297
- **Common Causes:**
288-
- XCM message blocked by safety barriers
289-
- Origin not authorized for operation
290-
- Asset transfer limits exceeded
291-
- Unsupported XCM version or instruction
298+
- XCM message blocked by safety barriers
299+
- Origin not authorized for operation
300+
- Asset transfer limits exceeded
301+
- Unsupported XCM version or instruction
292302

293303
- **Prevention:**
294-
- Verify XCM barrier configuration on the destination
295-
- Ensure origin has proper permissions
296-
- Check asset transfer limits and restrictions
297-
- Use supported XCM version and instructions
304+
- Verify XCM barrier configuration on the destination
305+
- Ensure origin has proper permissions
306+
- Check asset transfer limits and restrictions
307+
- Use supported XCM version and instructions
298308

299309
You can find a full list of XCM errors in the [Polkadot Rust Docs](https://paritytech.github.io/polkadot-sdk/master/cumulus_primitives_core/enum.XcmError.html){target=\_blank}.
300310

0 commit comments

Comments
 (0)