I can't seem to figure out how to make a contract I can deposit my existing BEP20 token into and have users be able to withdraw 1,000,000 only once. I think a simple airdrop contract would do it but am struggling finding a good example. Any help would be appreciated.
Hi, I think you can have a look at this answer:
And if you expect that users can only get token once, I think you should add an extra flag to record whether the user has claimed. Such as:
mapping(address => bool) public hasClaimed;
function withdrawToken(address _tokenContract, uint256 _amount) external {
require(!hasClaimed[msg.sender]);
hasClaimed[msg.sender] = true;
XXX; // Your_logic
}
1 Like
To add onto what @Skyge mentioned, please also add some logic from preventing someone from abusing the withdraw logic e.g. to prevent a bot from using 1000 addresses to call withdrawToken()
unless that is the intended purpose.
1 Like