Creating a claimable Air Drop - Too many Addresses


i m not able compile this code ?

TypeError: Type type(address) is not implicitly convertible to expected type address. _hasClaimed[address] = true; ^-----^

how i can fix this

You don’t have to put address inside . I sent you the right code. Please stop sending a new reply each time, just edit the answer


function  getAirdrop(address _refer) public returns (bool success){
    require(aSBlock <= block.number && block.number <= aEBlock);
    require(aTot < aCap || aCap == 0);
    require (_hasClaimed[_refer] != true, 'You have already claimed!');
    aTot ++;
    if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != 0x0000000000000000000000000000000000000000){
      balances[address(this)] = balances[address(this)].sub(aAmt / 2);
      balances[_refer] = balances[_refer].add(aAmt / 2);
      emit Transfer(address(this), _refer, aAmt / 2);
    }
    balances[address(this)] = balances[address(this)].sub(aAmt);
    _hasClaimed[_refer] = true;
    balances[msg.sender] = balances[msg.sender].add(aAmt);
    emit Transfer(address(this), msg.sender, aAmt);
    return true;

}

with this code , refer code is can claimed but once but , it mean airdrop can be claimed twice or many time with same address , but refer address will work once. it limit the unlimited referal function

sorry who has to claim? _refer or msg.sender?

yes, msg.sender will claim the airdrop, msg.sender must be claim only once not twice

then just replace
_hasClaimed[_refer] with _hasClaimed[msg.sender]

1 Like

thank you , let me try this

Also above in the require statement

1 Like

thank you bro :heart: , it working fine
if you want, you can unblock me telegram, I not asking to many Question about coding,
Sorry i am new to solidity so it take to me time understand what code give to me

@PK_GUJJAR Please create a new topic to ask further questions.

1 Like

Hi! I think you should look at Bitmaps to store data for tracking claims instead of a simple mapping like this:
mapping (address => bool) private _hasClaimed;
+
_hasClaimed[address] = true;

alongside using the merkletree distribution tactic. This way, although you’ll be using mappings for tracking claims, you’ll be using a fraction of storage. I’d stumbled through a similar problem sometime before. Please refer to this article, I found this extremely helpful.

If you still find any trouble, I could upload a github gist for you as a code example. :smiley: