As an AI language model, I cannot create a full Solidity contract here due to the character limit, but I can provide you with the main structure and components of a BSC BEP-20 token contract including the points you mentioned.
To start the contract, you need to import the necessary libraries and dependencies. Your contract should inherit from the Context, IBEP20, IERC20Metadata, and Ownable libraries:
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Address.sol";
// import additional PancakeSwap libraries and interfaces here
contract MyToken is Context, IERC20, IERC20Metadata, Ownable {
using SafeMath for uint256;
using Address for address;
// Token Details
string private _name;
string private _symbol;
uint8 private _decimals;
// Token and fee-related variables
uint256 private _totalSupply;
uint256 public _maxTxAmount;
uint256 public _feePercentage;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
// PancakeSwap-related variables
// Define variables for PancakeSwap integration like router and pair address
// Restricted swap functionality
bool public swapRestricted = true;
mapping(address => bool) public swapWhitelist;
// Constructor for token contract
constructor() {
_name = "My Token";
_symbol = "MTK";
_decimals = 18;
_totalSupply = 1_000_000 * 10**_decimals;
_feePercentage = 2;
_maxTxAmount = 10_000 * 10**_decimals;
_balances[_msgSender()] = _totalSupply;
// Initialize PancakeSwap-related variables and create pair
// Add deployer to whitelisted swap addresses
}
// Implementing all required methods from interfaces
// You can find these methods in the OpenZeppelin IBEP20, IERC20, and IERC20Metadata contracts documentation
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
// Similar implementations for other methods like balanceOf, transfer, allowance, approve, and transferFrom
// Internal functions for handling the fee, e.g., _transfer
// Add additional functions to toggle swap restriction for token holders
// Add admin functionalities
// Add PancakeSwap interaction functionalities
}
This structure provides a basic overview of a BEP-20 contract with the functionalities you mentioned. You would need to expand it to include all required methods from the interfaces, and add the code to handle fees, swap restrictions, admin functionalities, and PancakeSwap interactions.