unique-chain
unique-chain copied to clipboard
Substrate node of Unique Network
Unique Parachain
Project Description
The Unique Pallet is the core of NFT functionality. Like ERC-721 standard in Ethereum ecosystem, this pallet provides the basement for creating collections of unique non-divisible things, also called Non Fungible Tokens (NFTs), minting NFT of a given Collection, and managing their ownership.
The pallet also enables storing NFT properties. Though (according to ERC-721) NFT properties belong to logic of a concrete application that operates a Collection, so purposefully the NFT Tracking Module does not have any knowledge about properties except their byte size leaving application logic out to be controlled by Smart Contracts.
The Unique Chain also provides:
- Smart Contracts Pallet and example smart contract that interacts with Unique Runtime
- ERC-1155 Functionality (currently PoC as Re-Fungible tokens, i.e. items that are still unique, but that can be split between multiple users)
- Variety of economic options for dapp producers to choose from to create freemium games and other ways to attract users. As a step one, we implemented an economic model when a collection sponsor can be set to pay for collection Transfer transactions.
Wider Unique Ecosystem (most of it was developed during Hackusama):
Please see our walk-through instructions to try everything out!
Application Development
If you are building an application that operates NFT tokens, use this document.
Building
Building Unique chain requires special versions of Rust and toolchain. We don't use the most recent versions of everything so that we can keep the builds stable.
- Install Rust:
sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make cmake
curl https://sh.rustup.rs -sSf | sh
-
Remove all installed toolchains with
rustup toolchain list
andrustup toolchain uninstall <toolchain>
. -
Install toolchain nightly-2022-05-11 and make it default:
rustup toolchain install nightly-2022-05-11
rustup default nightly-2022-05-11
- Add wasm target for nightly toolchain:
rustup target add wasm32-unknown-unknown --toolchain nightly-2022-05-11
- Build:
Opal
cargo build --release
Quartz
cargo build --features=quartz-runtime --release
Unique
cargo build --features=unique-runtime --release
Building as Parachain locally
Note: checkout this project and all related projects (see below) in the sibling folders (both under the same folder)
Polkadot launch utility
git clone https://github.com/UniqueNetwork/polkadot-launch.git
git checkout feature/runtime-upgrade-testing
Build relay
git clone https://github.com/paritytech/polkadot.git
cd polkadot
git checkout release-v0.9.24
cargo build --release
Build Unique parachain
Run in the root of this project:
cargo build --release
Build Acala parachain (optional, full config only)
git clone https://github.com/AcalaNetwork/Acala
cd Acala
git checkout 54db3acd409a0b787f116f20e163a3b24101ce38
make build-release
Running as Parachain locally
./launch-testnet.sh
Optional, full setup with Acala and Statemint
./launch-testnet-full.sh
Run Integration Tests
- Install all needed dependecies
cd tests
yarn install
- Run tests
yarn test
Code Formatting
Apply formatting and clippy fixes
cargo clippy
cargo fmt
Format tests
pushd tests && yarn fix ; popd
Check code style in tests
cd tests && yarn eslint --ext .ts,.js src/
Karura token transfer
To get started, you need to open inbound and outbound hrmp channels.
Next, we need to register our asset at Karura.
assetRegistry -> registerForeignAsset(location, metadata)
location:
V0(X2(Parent, Parachain(PARA_ID)))
metadata:
name QTZ
symbol QTZ
decimals 18
minimalBalance 1
Next, we can send tokens from Quartz to Karura:
polkadotXcm -> reserveTransferAssets
dest:
V0(X2(Parent, Parachain(<KARURA_PARA_ID>)))
beneficiary:
X1(AccountId(Any, <ACCOUNT>))
assets:
V1(Concrete(0,Here), Fungible(<AMOUNT>))
feeAssetItem:
0
weightLimit:
<LIMIT>
The result will be displayed in ChainState tokens -> accounts
To send tokens from Karura to Quartz:
xtokens -> transfer
currencyId:
ForeingAsset
<TOKEN_ID>
amount:
<AMOUNT>
dest:
V1
(
Parents:1,
X2(Parachain(<KARURA_PARA_ID>), AccountId(Any, <ACCOUNT>)
)
destWeight:
<WEIGHT>