☑️Whitelist smart contract

🌊 Intro

This repository provides an implementation of Whitelist interface proposed in the TZIP-15 written in SmartPy: Python library for constructing Tezos SC and compiled to Michelson code. The contract is migrated from the Lorentz whitelisting contract.

💡 Why a whitelist contract?

The purpose of the Whitelist contract is to validate transfers so the token's contract holder can control which users can perform such operations. The Whitelist contract contains a list of users and entities that have satisfied the euroTz KYC/AML compliance procedures and thus are eligible to hold euroTz Tokens.

🔔 Specifications

UserID

As userID, we use the user's public key hash, e.g. a tz1 address.

Storage

whitelists:

big_map (
         key = whitelistID: Nat,
         value = {
         unrestricted: Bool,
         allowedWhitelists: set(whitelistID)
        })

users:

admin: address

issuer: address

🚀 We use the interface as an on-chain wrapper:

  1. The whitelist contract is deployed separately from our euroTz contract.

  2. The assertion entrypoints are called from euroTz contract, without requiring callbacks since they call FAILWITH when they fail.

How does our wrapper whitelist SC work?

🎥 Main scenarios:

  1. Issuer may transfer to bob ONLY if bob's is an asserted receiver, in other words, bob must be added to the users big_map and his whitelistID must be set and unrestricted in the whitelists big_map.

  2. Alice may transfer to Bob ONLY if bob and Alice are asserted users AND Bob's whitelistID is in Alice's allowedWhitelists.

⬇️ Get the Project:

  1. Clone the project & cd to the directory;

  2. Install the packages with yarn install.

🔍 EntryPoints (SC methods):

EntryPoint

Params (type / desc.)

Permission

Type

addUser

address (address) / whitelistID (option(nat))

Admin

Management

setWhitelistOutbound

whitelistID (nat) / option(allowed_whitelists (set) / unrestricted (bool))

Admin

Management

setAdmin

address (address)

Admin

Management

setIssuer

address (address)

Admin

Management

getAdmin

address (address / KT1 view contractAddress)

Any

Informative

getIssuer

address (address / KT1 view contractAddress)

Any

Informative

getWhitelist

address (address / KT1 view contractAddress) / whitelistID (nat)

Any

Informative

getUser

address (address / KT1 view contractAddress) / address (address / userAddress)

Any

Informative

assertReceiver

address (address)

Any

Assertion

assertReceivers

set (set(address))

Any

Assertion

assertTransfer

from_ (address) / to_ (address)

Any

Assertion

assertTransfers

set (set({from_: address, to_: address}))

Any

Assertion

Visit TZIP-15 to get a more developed description of the whitelist contract entrypoints.

👀 Tests Cases

The smartContract tests are written in smartPy and in JS (with Taquito, Mocha and Chai)

To launch tests, you have to:

  1. Originate the whitelist contract with:

  2. Paste the address of the originated whitelist SC in the conf file under /conf as following:

  1. Originate the euroTz contract with:

  2. Paste the address of the originated euroTz SC in the same conf file as follows:

🎉 You're ready to launch tests now...

The following tests use as

• whitelist contract address: KT1PFj9vshZKrHYLCswxUXKtY89SDYkXThDC

• euroTz contract address: KT1WcxYBrh9WwRo1vkbSJxAqr6ZVAUqDEiFg

Management entrypoints

Test Output:

Test Output:

Test Output:

Test Output:

Informative entrypoints

Test Output:

Assertion entrypoints

⚠️ In order to mint some euroTz tokens to the Issuer, you must launch the assertReceiver test before the assertTrasnfer one.

Test Output:

Test Output:

Test Output:

Test Output:

👮 Roles:

  1. Admin: the contract's owner and manager, he can:

    • Set a new contract's admin;

    • Set a new contract's issuer;

    • Add / Update / Delete any user in the users big_map;

    • Add / Update / Delete any whitelist in the whitelists big_map.

  2. Issuer:

    • Can't be explicitly added to users;

    • Is always unrestricted;

    • Whose allowedWhitelists is the set of ALL whitelistId's

🔗 Implementations

  • An implementation of wrapping and non-wrapping forms in Lorentz may be found here

  • A partial implementation of the compile-time wrapping form in LIGO may be found here

Last updated

Was this helpful?