📄Airdropper Contract
Contract roles:
Role
Description
DEPLOYER_ROLE (onlyDeployer)
Deployer is the address used to deploy the airdrop contract with a specified ERC20 token
OWNER_ROLE (onlyOwner)
Deployer is the hot wallet address of airdropper.xyz
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
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.
⚠️ Note:
The function is available only if the
DEPLOYER_ROLEactivated the airdrop.You can only call it once with your address! Any futher attempts will result in a failed transaction.
getAddresses() - Public
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
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
setDropAmount() - onlyDeployer or onlyOwnerfunction 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
enableAirdrop() - onlyDeployer or onlyOwnerfunction 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
disableAirdrop() - onlyDeployer or onlyOwnerfunction 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
Was this helpful?