# Airdropper Contract

## Contract roles:&#x20;

| 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

```typescript
ERC20 public token;
```

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

### dropAmount - uint256

```typescript
uint256 public dropAmount;
```

The total amount of tokens that can be claimed.&#x20;

### dropCount - uint

```typescript
uint public dropCount;
```

The number of addresses that claimed the airdrop.

### active - bool

```typescript
bool public active;
```

Boolean that represents the state of the airdrop.&#x20;

## Public Functions

### `getAirdrop()` - Public

```typescript
    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.

:warning: **Note:**&#x20;

* 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

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

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

### `tokenAmountLeft()` - Public

```typescript
    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

```typescript
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()`](#getairdrop-public) function.

### `enableAirdrop()` - onlyDeployer or onlyOwner

```typescript
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()`](#getairdrop-public) function to work.

### `disableAirdrop()` - onlyDeployer or onlyOwner

```typescript
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()`](#getairdrop-public) function.
