☑️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
UserIDAs 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:
The whitelist contract is deployed separately from our euroTz contract.
The assertion entrypoints are called from euroTz contract, without requiring callbacks since they call
FAILWITHwhen they fail.
How does our wrapper whitelist SC work?
🎥 Main scenarios:
Issuermay transfer tobobONLY ifbob's is an asserted receiver, in other words, bob must be added to theusersbig_map and hiswhitelistIDmust be set andunrestrictedin thewhitelistsbig_map.Alicemay transfer toBobONLY ifbobandAliceare asserted users ANDBob's whitelistID is inAlice'sallowedWhitelists.
⬇️ Get the Project:
Clone the project & cd to the directory;
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:
Originate the whitelist contract with:
Paste the address of the originated whitelist SC in the conf file under
/confas following:
Originate the euroTz contract with:
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:
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
usersbig_map;• Add / Update / Delete any whitelist in the
whitelistsbig_map.Issuer:
• Can't be explicitly added to
users;• Is always
unrestricted;• Whose
allowedWhitelistsis the set of ALLwhitelistId's
🔗 Implementations
Last updated
Was this helpful?