Following section will guide you through implementation of the xcNFT cross-chain pallet for non-fungible assets.
Pallet docs - [link]
Before you begin with implementing this magical ✨ pallet into your Parachain, you must ensure, that you meet following pre-requirements:
Substrate:
frame-benchmarking
frame-support
frame-system
Cumulus:
cumulus-primitives-core
cumulus-pallet-xcm
XCMP:
xcm
SP:
sp-runtime
sp-std
sp-core
sp-io
Substrate Pallets:
- Either
pallet-nfts
orpallet-uniques
depending on which pallet your Parachain uses pallet-balances
parachain-info
Other pallets (Only needed for pallet_uniques xcnft version):
enumflags2
- If your Parachain uses pallet_nfts head over to xcnft for pallet_nfts section.
- If your Parachain uses pallet_uniques head over to xcnft for pallet_uniques section.
Don't know whether this pallet is useful for your Parachain?
No worries!
Try it out before you implement it!
Make sure your docker deamon is running Copy the Dockerfile from this repository and input following commands:
docker build --platform linux/x86_64 -t polkadot-sdk-image:latest .
to build Docker imagedocker run --platform linux/x86_64 -p 9910-9913:9910-9913 -p 9920-9921:9920-9921 --rm -it polkadot-sdk-image:latest
to start Zombienet.
Once Zombienet is started, continue from step 8 in the next section.
-
Fork or clone following repository
-
Download Zombienet binary for your system
-
Copy zombienet binary into binaries folder of the repository you just forked
-
Compile Relay chain by:
cd polkadot
cargo build --release
- Compile first Parachain by:
cargo b -r -p parachain-template-node
- Compile second Parachain by:
cargo b -r -p parachain-template-node-two
- Launch zombienet localhost network by:
cd binaries
- Choose config that you wish to test:
./zombienet-macos-arm64 -p native -c 1 spawn config-both.toml
launches network with 1 Relay chain, 1 Parachain with pallet_nfts and 1 Parachain with pallet_uniques (Best for testing pallet agnosticity)./zombienet-macos-arm64 -p native -c 1 spawn config-nfts.toml
launches network with 1 Relay chain and 2 Parachains with pallet_nfts./zombienet-macos-arm64 -p native -c 1 spawn config-uniques.toml
launches network with 1 Relay chain and 2 Parachains with pallet_uniques
- Once the network is launched, connect to one of the Relay chain nodes:
- Open HRMP channels for both chains (Needed for allowing cross-chain communication):
- Navigate to
Extrinsics
tab selectAlice
account and go toDecode
- Paste following hash to Decode section:
0xff00fa05e8030000e90300000800000000040000
(This hash opens channel from chain 1000 to 1001) - Move back to Submission and sign the call with Alice
- Paste following hash to Decode section
0xff00fa05e9030000e80300000800000000040000
(This hash opens channel from chain 1001 to 1000) - Move back to Submission and sign the call with Alice
- Paste following hash to Decode section:
- Start interacting with chains by connecting to their WS endpoints from Zombienet console and try xcNFT out.
Don't know which function does what? Unsure what storage stores what?
Head over to User guide section.
To test the pallet we constructed various unit tests with variations of data. To run these tests use command:
Clone the following repository and run the following commands:
cargo test --package pallet-parachain-xcnft --lib -- tests --nocapture
cargo test --package pallet-parachain-xcnft-two --lib -- tests --nocapture
Soon (After pallet_nfts and pallet_uniques get released to newest version):
Choose pallet version and go to it's folder:
cd xcnft-pallet_nfts || xcnft-pallet_uniques
Run tests and benchmarks
cargo test
Made with 💛 by ParaSpell-Research✨
Published under MIT License.