Airdrop Manager Smart Contract on Conflux eSpace

:rocket: Building an Airdrop Manager Smart Contract on Conflux eSpace

In this blog, we’ll walk through how to build and deploy a simple yet powerful Airdrop Manager smart contract using Solidity and OpenZeppelin, designed to run on the Conflux eSpace testnet.

Whether you’re distributing tokens to early adopters, community members, or partners, this Airdrop Manager gives you complete control over token allocation and claiming.


:brain: What is an Airdrop Manager?

An Airdrop Manager smart contract allows a project owner to:

  • Set a list of recipient addresses
  • Assign token amounts for each recipient
  • Allow each recipient to claim their tokens only once
  • Optionally recover any unclaimed tokens

This ensures a fair, transparent, and decentralized token distribution system.


:hammer_and_wrench: Smart Contracts Used

:small_blue_diamond: MyToken.sol – The ERC-20 Token

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor() ERC20("TestingToken", "TTKN") {
        _mint(msg.sender, 10000 * 10 ** decimals());
    }
}

This contract mints 10,000 tokens to the deployer.


:small_blue_diamond: AirdropManager.sol – Airdrop Logic

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract AirdropManager is Ownable {
    IERC20 public token;
    mapping(address => uint256) public airdropAmounts;
    mapping(address => bool) public hasClaimed;

    event AirdropSet(address indexed recipient, uint256 amount);
    event AirdropClaimed(address indexed recipient, uint256 amount);

    constructor(address _token) Ownable(msg.sender) {
        token = IERC20(_token);
    }

    function setAirdrops(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
        require(recipients.length == amounts.length, "Length mismatch");

        for (uint256 i = 0; i < recipients.length; i++) {
            airdropAmounts[recipients[i]] = amounts[i];
            emit AirdropSet(recipients[i], amounts[i]);
        }
    }

    function claim() external {
        require(!hasClaimed[msg.sender], "Already claimed");
        uint256 amount = airdropAmounts[msg.sender];
        require(amount > 0, "No airdrop set");

        hasClaimed[msg.sender] = true;
        require(token.transfer(msg.sender, amount), "Token transfer failed");

        emit AirdropClaimed(msg.sender, amount);
    }

    function recoverUnclaimedTokens() external onlyOwner {
        uint256 balance = token.balanceOf(address(this));
        token.transfer(owner(), balance);
    }
}

:test_tube: How It Works

  1. Deploy MyToken – a basic ERC-20 token.
  2. Deploy AirdropManager, passing in the token address.
  3. Transfer tokens from the owner to the AirdropManager contract.
  4. Set airdrop allocations using setAirdrops(addresses[], amounts[]).
  5. Recipients call claim() to receive their tokens.
  6. Owner can recover unclaimed tokens after the airdrop ends.

:framed_picture: Demo Screenshots / Video

Watch the full walkthrough video here:


:link: Download Smart Contracts

:file_folder: View on GitHub


:white_check_mark: Conclusion

The AirdropManager is a simple and flexible solution for managing token distributions securely on-chain. It prevents double claims, ensures transparency, and gives owners the ability to reclaim unused tokens — making it ideal for Web3 projects, DAOs, and community incentives.


:mailbox_with_mail: Stay Connected

Follow me for more tutorials and smart contract breakdowns:

Thanks for reading! :raised_hands: