Skip to content

The-Poolz/WhiteList

Repository files navigation

WhiteList

Build Status codecov CodeFactor

WhiteList is a smart contract that creates a mechanism to explicitly allow certain identified addresses to access a certain privilege. This is the opposite of a blacklist, which is a list of prohibited things when everything is allowed by default.

Navigation

Installation

npm install

Testing

truffle run coverage

Deployment

truffle dashboard
truffle migrate --network dashboard

How's it work?

The WhiteList contract provides the ability to create an unlimited number of whitelists, the CreateManualWhiteList function is responsible for this. The address that created the whitelist automatically receives the Creator role.

function CreateManualWhiteList(
uint256 _ChangeUntil,
address _Contract
) public payable returns (uint256 Id) {

  • _ChangeUntil is specifies the time during which the whitelist is active. After its expiration, interaction with the current whitelist will be impossible!
  • By default, the added address (User) in the whitelist has a certain allocation value._Contract is address that is allowed to shorten the allocation in the whitelist. This opens up the possibility of interacting with other smart contracts, allowing them to change the distribution. Whitelist interface for using third-party smart contracts.
  • Each whitelist has a unique id returned when it is created, which can be used to determine its uniqueness.

NOTICE: Contract role can be passed to a normal user address. The input address will be able to use the Register and LastRoundRegister functions.

CreateManualWhiteList example of a transaction in a blockchain scanner.

Add address to whitelist

The Creator defines the whitelist members by specifying an array and a distribution of their amounts.

function AddAddress(uint256 _Id, address[] calldata _Users, uint256[] calldata _Amount)
Each added address will be automatically added to the whitelist in the presence of an allocation.

AddAddress example of a transaction in a blockchain scanner.

Remove address from whitelist

function RemoveAddress(uint256 _Id, address[] calldata _Users)
Each removable address will receive a zero allocation value in the whitelist.

RemoveAddress example of a transaction in a blockchain scanner.

Check address allocation

Want to check if an address is whitelisted? Check function returns user allocation.

function Check(address _user, uint256 _id) public view returns(uint){

User registration

There are two ways to reduce the allocation of Subject by a certain value: the first is to use the AddAddress function, the second is the Register function. The main difference between them is that Register can only use the Contract role.

function Register(
address _Subject,
uint256 _Id,
uint256 _Amount
) external {

Last round register

The LastRoundRegister opens the possibility of disabling the scope of allocation restrictions.

function LastRoundRegister(
address _Subject,
uint256 _Id
) external {

  • Each added _Subject will receive the maximum possible allocation.
  • Only the Contract role can use this function.

Change creator

function ChangeCreator(uint256 _Id, address _NewCreator)
In situations where the contract creates a whitelist and it is necessary to transfer the creator's right to a specific address, the ChangeCreator function can help us. Or we just need to update the creator role.

ChangeCreator example of a transaction in a blockchain scanner.

Contract diagram

classDiagram

License

The-Poolz Contracts is released under the MIT License.