Skip to content

Commit

Permalink
[Content migration] - Asset Hub introduction, Register a Local Asset …
Browse files Browse the repository at this point in the history
…& Register a Foreign Asset (#59)

* fix: adding asset-hub introduction to polkadot protocol section

* fix: adding register a local asset page and corresponding images

* fix: adding register a foreign asset on asset hub and corresponding images

* fix: updating foreign asset hub instance on paseo asset hub

* fix: removing rococo from list of testing networks for assety hub
  • Loading branch information
nhussein11 authored Oct 3, 2024
1 parent c242717 commit f37b35f
Show file tree
Hide file tree
Showing 19 changed files with 287 additions and 0 deletions.
3 changes: 3 additions & 0 deletions develop/parachain-devs/system-parachains/.pages
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
title: System Parachains
nav:
- index.md
- 'Register a Local Asset on Asset Hub': register-a-local-asset-on-asset-hub.md
- 'Register a Foreign Asset on Asset Hub': register-a-foreign-asset-on-asset-hub.md

Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
title: Register a Foreign Asset on Asset Hub
description: An in-depth guide to registering a foreign asset on the Asset Hub parachain, providing clear, step-by-step instructions.
---

# Register a Foreign Asset on Asset Hub

## Introduction

As outlined in the [Asset Hub Overview](TODO:update-path){target=\_blank}, Asset Hub supports two categories of assets: local and foreign. Local assets are created on the Asset Hub system parachain and are identified by integer IDs. On the other hand, foreign assets, which originate outside of Asset Hub, are recognized by [Multilocations](https://wiki.polkadot.network/docs/learn/xcm/fundamentals/multilocation-summary){target=\_blank}.

When registering a foreign asset on Asset Hub, it's essential to notice that the process involves communication between two parachains. The Asset Hub parachain will be the destination of the foreign asset, while the source parachain will be the origin of the asset. The communication between the two parachains is facilitated by the [Cross-Chain Message Passing (XCMP)](https://wiki.polkadot.network/docs/learn-xcm){target=\_blank} protocol.

This guide will take you through the process of registering a foreign asset on the Asset Hub parachain.

## Prerequisites

The Asset Hub parachain is one of the system parachains on a relay chain, such as [Polkadot](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fpolkadot.api.onfinality.io%2Fpublic-ws#/explorer){target=\_blank} or [Kusama](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkusama.api.onfinality.io%2Fpublic-ws#/explorer){target=\_blank}. To interact with these parachains, you can use the [Polkadot.js Apps](https://polkadot.js.org/apps/#/explorer){target=\_blank} interface for:

- [Polkadot Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fasset-hub-polkadot-rpc.dwellir.com#/explorer){target=\_blank}
- [Kusama Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fsys.ibp.network%2Fstatemine#/explorer){target=\_blank}

For testing purposes, you can also interact with the Asset Hub instance on the following test networks:

- [Paseo Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fpas-rpc.stakeworld.io%2Fassethub#/explorer){target=\_blank}

Before you start, ensure that you have:

- Access to the Polkadot.js Apps interface, and you are connected to the desired chain
- A parachain that supports the XCMP protocol to interact with the Asset Hub parachain
- A funded wallet to pay for the transaction fees and subsequent registration of the foreign asset

This guide will use Polkadot, its local Asset Hub instance, and the [Astar](https://astar.network/){target=\_blank} parachain (`ID` 2006), as stated in the [Test Environment Setup](#test-environment-setup) section. However, the process is the same for other relay chains and their respective Asset Hub parachain, regardless of the network you are using and the parachain owner of the foreign asset.

## Steps to Register a Foreign Asset

### Asset Hub

1. Open the [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface and connect to the Asset Hub parachain using the network selector in the top left corner

- Testing foreign asset registration is recommended on TestNet before proceeding to MainNet. If you haven't set up a local testing environment yet, consult the [Environment setup](#test-environment-setup) guide. After setting up, connect to the Local Node (Chopsticks) at `ws://127.0.0.1:8000`
- For live network operations, connect to the Asset Hub parachain. You can choose either Polkadot or Kusama Asset Hub from the dropdown menu, selecting your preferred RPC provider.

2. Navigate to the **Extrinsics** page
1. Click on the **Developer** tab from the top navigation bar
2. Select **Extrinsics** from the dropdown

![Access to Developer Extrinsics section](/images/develop/parachain-devs/system-parachains/register-a-foreign-asset-on-asset-hub/register-a-foreign-asset-1.webp)

3. Select the Foreign Assets pallet
3. Select the **`foreignAssets`** pallet from the dropdown list
4. Choose the **`create`** extrinsic

![Select the Foreign Asset pallet](/images/develop/parachain-devs/system-parachains/register-a-foreign-asset-on-asset-hub/register-a-foreign-asset-2.webp)

3. Fill out the required fields and click on the copy icon to copy the **encoded call data** to your clipboard. The fields to be filled are:

- **id** - as this is a foreign asset, the ID will be represented by a Multilocation that reflects its origin. For this case, the Multilocation of the asset will be from the source parachain perspective:

```javascript
MultiLocation {parents: 1, interior: X1(Parachain(2006))};
```

- **admin** - refers to the account that will be the admin of this asset. This account will be able to manage the asset, including updating its metadata. As the registered asset corresponds to a native asset of the source parachain, the admin account should be the sovereign account of the source parachain

??? note "Obtain the sovereign account"
The sovereign account can be obtained through [Substrate Utilities](https://www.shawntabrizi.com/substrate-js-utilities/){target=\_blank}.

Ensure that **Sibling** is selected and that the **Para ID** corresponds to the source parachain. In this case, since the guide follows the test setup stated in the [Test Environment Setup](#test-environment-setup) section, the **Para ID** is `2006`.

![Get parachain sovereign account](/images/develop/parachain-devs/system-parachains/register-a-foreign-asset-on-asset-hub/register-a-foreign-asset-3.webp)


- **`minBalance`** - the minimum balance required to hold this asset

![Fill out the required fields](/images/develop/parachain-devs/system-parachains/register-a-foreign-asset-on-asset-hub/register-a-foreign-asset-4.webp)

??? note "Encoded call data"
If you want an example of the encoded call data, you can copy the following:
```
0x3500010100591f007369626cd6070000000000000000000000000000000000000000000000000000a0860100000000000000000000000000
```


### Source Parachain

1. Navigate to the **Developer > Extrinsics** section
2. Create the extrinsic to register the foreign asset through XCM
1. Paste the **encoded call data** copied in the previous step
2. Click the **Submit Transaction** button

![Register foreign asset through XCM](/images/develop/parachain-devs/system-parachains/register-a-foreign-asset-on-asset-hub/register-a-foreign-asset-5.webp)

This XCM call involves withdrawing DOT from the sibling account of the parachain, using it to initiate an execution. The transaction will be carried out with XCM as the origin kind, and will be a hex-encoded call to create a foreign asset on Asset Hub for the specified parachain asset multilocation. Any surplus will be refunded, and the asset will be deposited into the sibling account.

!!! warning
Note that the sovereign account on the Asset Hub parachain must have a sufficient balance to cover the XCM `BuyExecution` instruction. If the account does not have enough balance, the transaction will fail.

??? note "Example of the encoded call data"
If you want to have the whole XCM call ready to be copied, go to the **Developer > Extrinsics > Decode** section and paste the following hex-encoded call data:
```
0x6300330003010100a10f030c000400010000070010a5d4e81300010000070010a5d4e80006030700b4f13501419ce03500010100591f007369626cd607000000000000000000000000000000000000000000000000000000000000000000000000000000000000
```

Ensure to replace the encoded call data with the one you copied in the previous step.

After the transaction is successfully executed, the foreign asset will be registered on the Asset Hub parachain.

## Asset Registration Verification

To confirm that a foreign asset has been successfully accepted and registered on the Asset Hub parachain, you can navigate to the `Network > Explorer` section of the Polkadot.js Apps interface for Asset Hub. You should be able to see an event that includes the following details:

![Asset registration event](/images/develop/parachain-devs/system-parachains/register-a-foreign-asset-on-asset-hub/register-a-foreign-asset-6.webp)

In the image above, the **success** field indicates whether the asset registration was successful.

## Test Environment Setup

To test the foreign asset registration process before deploying it on a live network, you can set up a local parachain environment. This guide uses Chopsticks to simulate that process. For more information on using Chopsticks, please refer to the [Chopsticks documentation](../../../dev-tools/chopsticks/overview.md){target=\_blank}.

To set up a test environment, run the following command:

```bash
npx @acala-network/chopsticks xcm \
--r polkadot \
--p polkadot-asset-hub \
--p astar
```
!!! note
The above command will create a lazy fork of Polkadot as the relay chain, its Asset Hub instance, and the Astar parachain. The `xcm` parameter enables communication through the XCMP protocol between the relay chain and the parachains, allowing the registration of foreign assets on Asset Hub. For further information on the chopsticks usage of the XCMP protocol, refer to the [XCM Testing](../../../dev-tools/chopsticks/overview.md#xcm-testing){target=\_blank} section of the Chopsticks documentation.

After executing the command, the terminal will display the subsequent output:

--8<-- 'code/build-on-polkadot/parachains/asset-hub/register-a-foreign-asset/terminal/chopstick-test-env-output.md'

According to the output, the Polkadot relay chain, the Polkadot Asset Hub, and the Astar parachain are running locally and connected through XCM. They can be accessed via the Polkadot.js Apps interface:

- [Polkadot Relay Chain](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Flocalhost%3A8002#/explorer){target=\_blank}
- [Polkadot Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Flocalhost%3A8000#/explorer){target=\_blank}
- [Astar Parachain](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Flocalhost%3A8001#/explorer){target=\_blank}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: Register a Local Asset
description: Comprehensive guide to registering a local asset on the Asset Hub system parachain, including step-by-step instructions.
---

# Register a Local Asset on Asset Hub

## Introduction

As detailed in the [Asset Hub Overview](TODO:update-path){target=\_blank} page, Asset Hub accommodates two types of assets: local and foreign. Local assets are those that were created in Asset Hub and are identifiable by an integer ID. On the other hand, foreign assets originate from a sibling parachain and are identified by a Multilocation.

This guide will take you through the steps of registering a local asset on the Asset Hub parachain.

## Prerequisites

Before you begin, ensure you have access to the [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface and a funded wallet with DOT or KSM.

- For Polkadot Asset Hub, you would need a deposit of 10 DOT and around 0.201 DOT for the metadata
- For Kusama Asset Hub, the deposit is 0.1 KSM and around 0.000669 KSM for the metadata

You need to ensure that your Asset Hub account balance is a bit more than the sum of those two deposits, which should seamlessly account for the required deposits and transaction fees.

## Steps to Register a Local Asset

To register a local asset on the Asset Hub parachain, follow these steps:

1. Open the [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank} interface and connect to the Asset Hub parachain using the network selector in the top left corner

- You may prefer to test local asset registration on TestNet before registering the asset on a MainNet hub. If you still need to set up a local testing environment, review the [Environment setup](#test-setup-environment) section for instructions. Once the local environment is set up, connect to the Local Node (Chopsticks) available on `ws://127.0.0.1:8000`
- For the live network, connect to the `Asset Hub` parachain. Either Polkadot or Kusama Asset Hub can be selected from the dropdown list, choosing the desired RPC provider

2. Click on the **Network** tab on the top navigation bar and select **Assets** from the dropdown list

![Access to Asset Hub through Polkadot.JS](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-1.webp)

3. Now, you need to examine all the registered asset IDs. This step is crucial to ensure that the asset ID you are about to register is unique. Asset IDs are displayed in the **assets** column

![Asset IDs on Asset Hub](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-2.webp)

4. Once you have confirmed that the asset ID is unique, click on the **Create** button on the top right corner of the page

![Create a new asset](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-3.webp)

5. Fill in the required fields in the **Create Asset** form:

1. **creator account** - the account to be used for creating this asset and setting up the initial metadata
2. **asset name** - the descriptive name of the asset you are registering
3. **asset symbol** - the symbol that will be used to represent the asset
4. **asset decimals** - the number of decimal places for this token, with a maximum of 20 allowed through the user interface
5. **minimum balance** - the minimum balance for the asset. This is specified in the units and decimals as requested
6. **asset ID** - the selected id for the asset. This should not match an already-existing asset id
7. Click on the **Next** button

![Create Asset Form](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-4.webp)

6. Choose the accounts for the roles listed below:

1. **admin account** - the account designated for continuous administration of the token
2. **issuer account** - the account that will be used for issuing this token
3. **freezer account** - the account that will be used for performing token freezing operations
4. Click on the **Create** button

![Admin, Issuer, Freezer accounts](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-5.webp)

7. Click on the **Sign and Submit** button to complete the asset registration process

![Sign and Submit](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-6.webp)

## Verify Asset Registration

After completing these steps, the asset will be successfully registered. You can now view your asset listed on the [**Assets**](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fasset-hub-polkadot-rpc.dwellir.com#/assets){target=\_blank} section of the Polkadot.js Apps interface.

![Asset listed on Polkadot.js Apps](/images/develop/parachain-devs/system-parachains/register-a-local-asset-on-asset-hub/register-a-local-asset-7.webp)

!!! note
Take into consideration that the **Assets** section’s link may differ depending on the network you are using. For the local environment, the link will be `ws://127.0.0.1:8000/#/assets`.

In this way, you have successfully registered a local asset on the Asset Hub parachain.

For an in-depth explanation of Asset Hub and its features, please refer to the Polkadot Wiki page on [Asset Hub](https://wiki.polkadot.network/docs/learn-assets){target=\_blank}.

## Test Setup Environment

You can set up a local parachain environment to test the asset registration process before deploying it on the live network. This guide uses `chopsticks` to simulate that process. For further information on chopsticks usage, refer to the [Chopsticks](TODO:update-path){target=\_blank} documentation.

To set up a test environment, execute the following command:

```bash
npx @acala-network/chopsticks \
--config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/polkadot-asset-hub.yml
```

!!!note
The above command will spawn a lazy fork of Polkadot Asset Hub with the latest block data from the network. If you need to test Kusama Asset Hub, replace `polkadot-asset-hub.yml` with `kusama-asset-hub.yml` in the command.

An Asset Hub instance is now running locally, and you can proceed with the asset registration process. Note that the local registration process does not differ from the live network process. Once you have a successful TestNet transaction, you can use the same steps to register the asset on MainNet.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions polkadot-protocol/system-parachains/asset-hub/.pages
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
title: Asset Hub
nav:
- index.md
- 'Asset Hub Introduction': asset-hub-introduction.md
- 'Asset Conversion': asset-conversion.md
Loading

0 comments on commit f37b35f

Please sign in to comment.