Help with functionality

I’m creating a staking dapp But i don’t want users to withdraw till they invite 1 friend each, so how can I block withdrawal access till someone join using my user’s referral link?

on deposit you can ask for address _referral
then you can create a mapping from address to uint and increase the count by one for each the referral.

mapping(address => uint) referrals

function deposit(address _referral) public {
 require(_referral != msg.sender, "cant referral yourself")
 referrals[_referral]++;
}

function withdraw() public {
 require(referrals[msg.sender] > 0, "you need atleast 1 referral");
}
1 Like

Thanks mate I’d appreciate you

No problem! If this was helpful please consider marking this as the solution.

1 Like