Created
August 19, 2023 16:02
-
-
Save MayowaObisesan/857ae90ad21dd52bb169712bf75b7425 to your computer and use it in GitHub Desktop.
This is a basic solidity contract that simulates how airDrops work. i.e., only eligible addresses will get the token to be airdropped. This is a sim, not an actual implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
// Create a contract called token where you will specify the name of the token, the total number of token | |
// that can be in circulation and have an allowList for addresses that can get your token. | |
contract Token { | |
string constant tokenName = "BToken"; | |
uint public token = 1000; | |
address[] allowList; | |
address owner = msg.sender; | |
mapping(address => bool) isEligible; | |
function setAddressLegible(address userAddress) public { | |
require(isEligible[userAddress] == false, "Address already has received token"); | |
// if statement no longer required below because of the `require` above. | |
// Just added the if statement to show what is expected. | |
if (!isEligible[userAddress]) { | |
allowList.push(userAddress); | |
isEligible[userAddress] = true; | |
token -= 1; | |
} | |
} | |
function canGetToken() view public returns (bool) { | |
return isEligible[owner]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment