Skip to content

azero-id/xcm-domain-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XCM Domain Service (PoC)

This repository contains a working PoC of a cross-parachain domain name service consisting of multiple XCM-enabled ink! smart contracts. It's part of the delivery for our W3F Grant (M1 Delivery, M2 Delivery).

The PoC domain name service implementation is a registry mapping between domain names, owning, and resolving addresses. Find a detailed contract walkthrough below and also check the inline ink! documentation for each function.


  1. Architecture
  2. Repository structure
  3. Getting started
    1. Prerequisites
    2. Setup instructions
    3. Fund your account via Faucet
  4. Unit tests via xcm-simulator
  5. Development environment

Architecture

architecture

Read more in the documents submitted as part of our M2 Delivery.

Repository structure

  1. contracts/: It contains the ink! smart contracts for xcm-domain-service.
  2. src/: It contains the mock xcm-simulator network and unit tests.
  3. zombienet/: It allows you to deploy a live local network using zombienet where you can interact with the cross-chain enabled domain service.

Getting started

Spawn a local network using Zombienet and experience the XCM domain service first-hand.

Prerequisites

You have configured your environment for Substrate development by installing Rust and the Rust toolchain.

Setup instructions

1. Clone the repo and navigate to the zombienet/ folder:

git clone https://github.com/azero-id/xcm-domain-service.git
cd xcm-domain-service/zombienet/

2. Make the zombienet.sh bash script executable:

chmod +x zombienet.sh

3. Install the polkadot, contracts-parachain & zombienet binaries:

./zombienet.sh init

Note

This can take a while (around 20+ minutes depending upon the system)… ☕

4. Spawn the network

./zombienet.sh spawn

This command spawns the following chains:

  • Relay Chain (ws_port: 9900)
  • Contracts Parachain #1 (ws_port: 9910) {Hub}
  • Contracts Parachain #2 (ws_port: 9920) {Spoke}

5. Deploy the contracts

Open a new shell with the same working directory and run:

cargo run

This will deploy the following contracts:

  • Domain-service on Parachain #1 (address: 5Dg8MLVcwDHAv5FjWBeeLute7M9yHXoic6oBYk97fpK2BXKx)
  • Xcm-handler on Parachain #1 (address: 5DhGtfSDhZHzQKTjzy2NFEwEXBtHzMEx68WdwJmHWSM6MTZJ)
  • Xc-domain-service on Parachain #2 (address: 5CAogDHwRT8pUkRBzBsPczKSMPULuh6Zg6zK3kQQzYtQUwYf)

Note

It can take some time (around 2-4 minutes) to complete the deployment.

6. Fund your account(s)

You will need funds in your account for the domain registration and gas fees, if not using pre-funded accounts like //Alice. Run the following command that will transfer 100 token units to the specified addresses:

cargo run -- fund <space-separated addresses>

7. Interact with the contracts

Open two contracts-ui pages on your preferred browser, one for each chain. Use the following links:

Click on Add New Contract and choose the Use On-chain Contract Address method. Add the contracts on the respective Contracts-UI page. It will ask for the metadata which you can find in the artefacts folder.

Note

You can skip this step for Xcm-handler contract.

Below you will find a sample order of interaction via xc_domain_service (Parachain #2):

  1. register_name(name): Register a domain. (fails if name is already claimed, refund not handled for simplicity).
  2. get_owner(name) -> TicketId: Request for the owner address of the given name.
  3. retrieve_owner(ticket_id): Get the owner details associated with the ticketId (if valid).
  4. set_address(name, multi_location): Set the resolving address in MultiLocation format for the given name.
  5. get_address(name) -> TicketId: Request for the resolving address details of the given name.
  6. retrieve_address(ticket_id): Get the address details associated with the TicketId (if valid).
  7. transfer_name(name, to): Transfer domain ownership

Alternatively, you can also interact with Domain-service on Parachain #1 directly (e.g. for double checking that the state changed consistently across chains).

Note

For more details refer to the inline documentation available for each contract message.

Unit tests via xcm-simulator

You will first need to build the contracts (domain_service, xcm_handler, and xc_domain_service) here. Then run the following command from the project root:

cargo test

Development environment

  • Rust Stable: rustc 1.72.0 (5680fa18f 2023-08-23)
  • Ink! v4.3.0
  • Cargo-contract 4.0.0-alpha
  • Relay/Para-chain nodes based on Polkadot release v1.0.0
  • Zombienet v1.3.69
  • System: Apple M2 Pro

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published