I need to write a smart contract where owner able to lock user. So that locked user can not send/receive token. Here is my code snippet,
mapping (address => bool) private _lock;
modifier onlyOwner() {
require (Owner == _msgSender(),"you don't have access to block");
_;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
require(!_lock[sender],"ERC20: sender is blocked");
require(!_lock[recipient],"ERC20: recipient is blocked");
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function lock (address addr) public onlyOwner returns(bool) {
_lock[addr] = true;
return _lock[addr];
}
function Unlock (address addr) public onlyOwner returns(bool) {
_lock[addr] = false;
return _lock[addr];
}
Is it proper way?