IAirdropERC1155Claimable Contract
This interface defines functions for airdropping ERC1155 tokens and allowing users to claim their allocated tokens.
Features
- Defines functions for setting the claim status of a user.
- Allows claiming allocated tokens.
- Provides methods for checking claim status and retrieving allocated tokens.
Usage
This interface is intended to be implemented by contracts that need to perform airdrops of ERC1155 tokens. It provides a standardized way to manage claims and track allocations.
Example Implementation
The following is an example of a contract that implements the `IAirdropERC1155Claimable` interface:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./IAirdropERC1155Claimable.sol";
contract AirdropERC1155Claimable is ERC1155, AccessControl, IAirdropERC1155Claimable {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
// Mapping to track claim status for each user
mapping(address => bool) public hasClaimed;
// Mapping to store the allocated tokens for each user
mapping(address => uint256[]) public userAllocations;
constructor(string memory _uri) ERC1155(_uri) {
_setupRole(ADMIN_ROLE, msg.sender);
}
function setClaimStatus(address _user, bool _isClaimed) public onlyRole(ADMIN_ROLE) {
hasClaimed[_user] = _isClaimed;
}
function claim() public {
require(!hasClaimed[msg.sender], "Already claimed");
// Get the user's allocated tokens
uint256[] memory tokens = userAllocations[msg.sender];
// Transfer allocated tokens to the user
_mint(msg.sender, tokens, new uint256[](tokens.length), "");
hasClaimed[msg.sender] = true;
}
// ... Other functions for managing allocations, etc.
}