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.
- Architecture
- Repository structure
- Getting started
- Unit tests via
xcm-simulator
- Development environment
Read more in the documents submitted as part of our M2 Delivery.
contracts/
: It contains the ink! smart contracts forxcm-domain-service
.src/
: It contains the mockxcm-simulator
network and unit tests.zombienet/
: It allows you to deploy a live local network usingzombienet
where you can interact with the cross-chain enabled domain service.
Spawn a local network using Zombienet and experience the XCM domain service first-hand.
You have configured your environment for Substrate development by installing Rust and the Rust toolchain.
git clone https://github.com/azero-id/xcm-domain-service.git
cd xcm-domain-service/zombienet/
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)… ☕
./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}
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.
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>
Open two contracts-ui
pages on your preferred browser, one for each chain. Use the following links:
- Contracts-UI for Parachain #1
- Contracts-UI for Parachain #2
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):
register_name(name)
: Register a domain. (fails if name is already claimed, refund not handled for simplicity).get_owner(name) -> TicketId
: Request for the owner address of the given name.retrieve_owner(ticket_id)
: Get the owner details associated with theticketId
(if valid).set_address(name, multi_location)
: Set the resolving address inMultiLocation
format for the givenname
.get_address(name) -> TicketId
: Request for the resolving address details of the given name.retrieve_address(ticket_id)
: Get the address details associated with the TicketId (if valid).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.
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
- 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