/quartz-tezos-contracts

Ubisoft Quartz smart contract sources and build tools

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Ubisoft Quartz contracts

Tezos smart contracts for Ubisoft Quartz NFT written in Archetype.

Architecture

The Quartz NFT (also known as Digits) are non-fungible FA2 tokens. Token minting and transfer is supervised by a contract that guarantees the Quartz rules such as collection size, whitelisting and quotas.

Each Quartz item type is referred here as an archetype. An archetype is a collection where each item has the same properties except for the unique serial number, owner and history.

Each archetype is defined by its id, the quota per wallet, and a contract that is responsible for the minting conditions. As of today, the only minting conditions is the collection size limit which only validates that the serial number is within the bounds.

Security

The Quartz contracts have been audited by Apriorit. The report can be found here.

Contracts

Quartz FA2

This is the core Quartz NFT contract. It implements TZIP-12 FA2 - Multi-Asset Interface, TZIP-16 Contract Metadata and TZIP-17 Contract Permit Interface

Additionally, transfers are subject to validation from the Archetype contract. For wallet and marketplace integration convenience, the following getter will indicate if a transfer is allowed: getter can_transfer(tokenid: nat, from_: address, to_: address): string See the contract doc for return codes.

Quartz Archetype

Application-specific logic is handled by this contract. It holds a reference to the FA2 contract, the whitelist, and the balance per archetype per user. For modularity purposes, the balances and archetype definitions (ledger) are stored in two separate storage contracts.

Quartz Whitelist

The whitelist contract is a TZIP-15 A2 Token Transferlist interface contract. Two transferlists are configured:

  • 0 is the main whitelist, users in the list can receive a Quartz NFT
  • 1 is the blacklist, users in the list cannot receive Quartz NFT. However, they can still transfer their NFT to the transferlist 0

Quartz Whitelist (whitelist.arl): KT1LEF2WLUJ2QqViWKYjYanYymVJ8gyjQnte Users storage (users_storage.arl): KT1J8yKdznsYoWmj3CAHt1xhS9Kf1UQgYJy6

Quartz minting validator

This contract implements a simple interface to validate the minting of NFT. It was designed to allow alternate conditions on the mint process. Today, the only implementation in use is the Standard Minting Validator (or Simple Minting validator) that only checks that the serial number limit is respected.

Quartz minter

To enable primary market NFT sales, a minter contract processes feeless stablecoin (Lugh EURL) payments and mints a Quartz NFT in a single operation.

Build, test, and deploy

Contracts are built using the Completium toolkit. The kit comes with a CLI that enables various tasks.

Install tezos-client.

Then, in the contract repository, install the NPM depedencies:

npm install

Setup accounts and initialize mockup chain

alias ccli="npx completium-cli"
ccli init
ccli generate account as quartz_admin
ccli generate account as quartz_minter
ccli generate account as quartz_whitelister
ccli generate account as quartz_user
mkdir -p ~/.completium/mockup # mockup folder is missing in some setups
ccli mockup init

Run unit tests

npm test

License

The Quartz contracts are available under the Apache 2.0 License

Credits

The Quartz Smart Contracts were ported to Archetype with the help from Nomadic Labs and the Completium team: Benoit Rognier and Guillaume Duhamel