I have been searching for hours and hours and days but i cannot find a way to deploy a spl token with a max wallet for each user such as , a wallet can buy only 2% of the supply , not more , is there any way possible to do this
1 Answer
You can actually do this using token extensions with the transfer hook extension.
In your transfer hook program, you would basically do the following pseudocode:
if amount > max_limit {
msg!("Transfer exceeds transfer limit");
return Err(CustomError::TransferNotAllowed.into());
}
That will keep any transfer greater than max_limit
from completing successfully. If you wanted to make sure the wallet itself didn't have more than that amount, you do the same check within the transfer hook program.
You can find more on transfer hooks and examples in the documentation.