📄Airdropper Contract

Contract roles:

Owner

0xtodo

Hot wallet address controlled by airdropper.xyz multisignature contract

Variables

token - ERC20

ERC20 public token;

The ERC20 token linked to the contract in order to be dropped.

dropAmount - uint256

uint256 public dropAmount;

The total amount of tokens that can be claimed.

dropCount - uint

uint public dropCount;

The number of addresses that claimed the airdrop.

active - bool

bool public active;

Boolean that represents the state of the airdrop.

Public Functions

getAirdrop() - Public

    function getAirdrop() public {
        // requirements
        require(active, "Airdrop is not activated.");
        require(hasClaimed[msg.sender] == false, "Only one airdrop is authorized.");

        // Change contract stats
        hasClaimed[msg.sender] = true;
        dropCount += 1;
        droppedAddresses.push(msg.sender);

        // Get the airdrop
        token.transfer(msg.sender, dropAmount);
    }

Everyone can call this function to claim the airdrop and receive the specified amount of tokens.

  • The function is available only if the DEPLOYER_ROLE activated the airdrop.

  • You can only call it once with your address! Any futher attempts will result in a failed transaction.

getAddresses() - Public

    function getAddresses() public view returns (address[] memory){
        return droppedAddresses;
    }

Everyone can call this function to see who benefited from the airdrop.

tokenAmountLeft() - Public

    function tokenAmountLeft() public view returns (uint256){
        return token.balanceOf(address(this));
    }

Everyone can call this function to see the amount of tokens left in the contract.

Owner Functions

setDropAmount() - onlyDeployer or onlyOwner

function setDropAmount(uint256 _dropAmount){
    require(isAuthorized(msg.sender), "DOES_NOT_HAVE_PERMISSION");
    dropAmount = _dropAmount * 10 ** tokenDecimal;
}

Only the DEPLOYER_ROLE or the OWNER_ROLE can call this function to disable the contract and the getAirdrop() function.

enableAirdrop() - onlyDeployer or onlyOwner

function enableAirdrop() external{
    require(isAuthorized(msg.sender), "DOES_NOT_HAVE_PERMISSION");
    active = true;
}

Only the DEPLOYER_ROLE or the OWNER_ROLE can call this function to activate the contract and allow the getAirdrop() function to work.

disableAirdrop() - onlyDeployer or onlyOwner

function disableAirdrop() external{
    require(isAuthorized(msg.sender), "DOES_NOT_HAVE_PERMISSION");
    active = false;
}

Only the DEPLOYER_ROLE or the OWNER_ROLE can call this function to disable the contract and the getAirdrop() function.

Last updated