At the moment I am working on an ERC20 token and I am trying to find the best solution for some people to receive a number of tokens but they cannot transfer it from one person to another for a year. Any best advice?
I read about _beforeTokenTransfer but I don't know if it's ideal to override the hook.
Maybe you can make an airdrop for users, and then they can claim their tokens by themselves or you can transfer tokens to them, it is up to you.
So once a user gets token, he can not transfer until one year later, right? If so, maybe you can add a lock time for transfer. You can also do this in the _beforeTokenTransfer.
Thank you for the answer !
I managed to make the contract smart using _beforeTokenTransfer but how could I add inside the function that specific time lock for locked addresses?
I did something like this.
mapping(address => bool) internal _LockList;
function LockAddress(address account) external onlyOwner returns (bool) {
_LockList[account] = true;
return true;
}
function unLockAddress(address account) external onlyOwner returns (bool) {
delete _LockList[account];
return true;
}
function LockedAddressList(address account) external view virtual returns (bool) {
return _LockList[account];
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override(ERC20)
{
require(!_LockList[from], "Token transfer from LockedAddressList");
super._beforeTokenTransfer(from, to, amount);
}
I didn't find anything in the forum search to help me.
You should set a time require around the transfer function or beforeTransfer function that checks if time is >= 1 year. May be you provide more detail of scope of what you are trying to do.