AirdropVault

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/AirdropContract.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
interface IERC20 {\r
    function transfer(address to, uint256 amount) external returns (bool);\r
    function transferFrom(address from, address to, uint256 amount) external returns (bool);\r
    function balanceOf(address account) external view returns (uint256);\r
}\r
\r
contract AirdropVault {\r
    address public owner;\r
\r
    struct TimestampAirdrop {\r
        uint256 amount;\r
        uint256 unlockTimestamp;\r
        bool claimed;\r
    }\r
\r
    struct BlockAirdrop {\r
        uint256 amount;\r
        uint256 unlockBlock;\r
        bool claimed;\r
    }\r
\r
    mapping(address => mapping(address => TimestampAirdrop)) public timestampAirdrops;\r
    mapping(address => mapping(address => BlockAirdrop)) public blockAirdrops;\r
\r
    modifier onlyOwner() {\r
        require(msg.sender == owner, "Not owner");\r
        _;\r
    }\r
\r
    event AirdropAdded(address indexed user, address indexed token, uint256 amount, uint256 unlockTimestamp);\r
    event AirdropClaimed(address indexed user, address indexed token, uint256 amount);\r
    event TokensWithdrawn(address indexed token, address indexed to, uint256 amount);\r
    event NativeWithdrawn(address indexed to, uint256 amount);\r
\r
    constructor() {\r
        owner = msg.sender;\r
    }\r
\r
    function addTimestampAirdrop(address user, address token, uint256 amount, uint256 unlockTimestamp) external onlyOwner {\r
        require(user != address(0), "Invalid user");\r
        require(amount > 0, "Amount must be > 0");\r
        require(unlockTimestamp > block.timestamp, "Unlock time must be in future");\r
\r
        timestampAirdrops[user][token] = TimestampAirdrop({\r
            amount: amount,\r
            unlockTimestamp: unlockTimestamp,\r
            claimed: false\r
        });\r
\r
        emit AirdropAdded(user, token, amount, unlockTimestamp);\r
    }\r
\r
    function withdrawTokens(address token, address to, uint256 amount) external onlyOwner {\r
        require(to != address(0), "Invalid address");\r
        IERC20 erc20 = IERC20(token);\r
        require(erc20.balanceOf(address(this)) >= amount, "Insufficient balance");\r
        erc20.transfer(to, amount);\r
        emit TokensWithdrawn(token, to, amount);\r
    }\r
\r
    function withdrawNative(address payable to, uint256 amount) external onlyOwner {\r
        require(to != address(0), "Invalid address");\r
        require(address(this).balance >= amount, "Insufficient balance");\r
        to.transfer(amount);\r
        emit NativeWithdrawn(to, amount);\r
    }\r
\r
    function claimTimestamp(address token) external {\r
        TimestampAirdrop storage drop = timestampAirdrops[msg.sender][token];\r
        require(drop.amount > 0, "No airdrop");\r
        require(!drop.claimed, "Already claimed");\r
        require(block.timestamp >= drop.unlockTimestamp, "Airdrop locked");\r
\r
        drop.claimed = true;\r
        IERC20(token).transfer(msg.sender, drop.amount);\r
\r
        emit AirdropClaimed(msg.sender, token, drop.amount);\r
    }\r
\r
    function claimBlock(address token) external {\r
        BlockAirdrop storage drop = blockAirdrops[msg.sender][token];\r
        require(drop.amount > 0, "No airdrop");\r
        require(!drop.claimed, "Already claimed");\r
        require(block.number >= drop.unlockBlock, "Airdrop locked");\r
\r
        drop.claimed = true;\r
        IERC20(token).transfer(msg.sender, drop.amount);\r
\r
        emit AirdropClaimed(msg.sender, token, drop.amount);\r
    }\r
\r
    receive() external payable {}\r
}\r
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
Factory|addr:0xe219b3dddd45620133435e5c0e5ac6d6ac683ab5|verified:true|block:23746908|tx:0x6bc91d379425c0784175252ef0c23729638592f6c73111a839ce22dba192fc03|first_check:1762519192

Submitted on: 2025-11-07 13:39:53

Comments

Log in to comment.

No comments yet.