Skip to content

UniqueNetwork/unique-chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ebfc6b1 · Jul 21, 2023
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Windows note: We do not provide support for Windows systems and don't test the Unique chain on them. Nonetheless, the Unique chain node might work on Windows. To build it on Windows, you need to enable symlink support in Git:

git config --global core.symlinks true
  1. Install Rust:
sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make cmake protobuf-compiler
curl https://sh.rustup.rs -sSf | sh
  1. Remove all installed toolchains with rustup toolchain list and rustup toolchain uninstall <toolchain>.

  2. Install toolchain nightly-2022-11-15 and make it default:

rustup toolchain install nightly-2022-11-15
rustup default nightly-2022-11-15
  1. Add wasm target for nightly toolchain:
rustup target add wasm32-unknown-unknown --toolchain nightly-2022-11-15
  1. 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 unique-network

Build relay

git clone https://github.com/paritytech/polkadot.git
cd polkadot
git checkout release-v0.9.43
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

  1. Install all needed dependecies
cd tests
yarn install
  1. 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:
	ForeignAsset
		<TOKEN_ID>

amount:
		<AMOUNT>
dest:
	V1
	(
		Parents:1,
		X2(Parachain(<KARURA_PARA_ID>), AccountId(Any, <ACCOUNT>)
	)
destWeight:
	<WEIGHT>