编译器
0.8.25+commit.b61c2a91
文件 1 的 10:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
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;
}
}
文件 2 的 10:ERC20TokenBase.sol
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
abstract contract ERC20TokenBase is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
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 virtual {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_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));
}
_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);
}
}
}
}
文件 3 的 10:Geopolitics.sol
pragma solidity ^0.8.25;
import "./Token.sol";
contract EthReceiver {
address public receiver;
constructor(address receiver_address) {
receiver = receiver_address;
}
modifier only_receiver() {
require(msg.sender == receiver, "only receiver");
_;
}
function set_receiver(address new_receiver) external only_receiver {
receiver = new_receiver;
}
}
contract Geopolitics is Token, EthReceiver {
address public game;
uint public tax_share = 150;
uint public constant max_tax_share = 150;
uint public game_share = 500;
uint public constant tax_share_precesion = 1000;
constructor(
address router_address
)
Token("GEOPOLITICS", "GEO", router_address)
EthReceiver(msg.sender)
{}
function set_tax_share(uint new_tax_share) external onlyOwner {
require(new_tax_share <= max_tax_share);
tax_share = new_tax_share;
}
function set_game_share(uint new_game_share) external onlyOwner {
require(new_game_share <= tax_share_precesion);
game_share = new_game_share;
}
function set_game(address new_game_address) external onlyOwner {
game = new_game_address;
}
function buy(
address to,
uint256 amount
) internal virtual override maxBuyLimit(amount) lockFee {
uint256 tax = (amount * tax_share) / tax_share_precesion;
if (tax > 0) {
if (game == address(0)) {
super._transfer(_pair, address(this), tax);
} else {
uint to_game = (tax * game_share) / tax_share_precesion;
uint to_token = tax - to_game;
if (to_game > 0) super._transfer(_pair, game, to_game);
if (to_token > 0)
super._transfer(_pair, address(this), to_token);
}
}
super._transfer(_pair, to, amount - tax);
}
function sell(
address from,
uint256 amount
) internal virtual override lockFee {
uint256 tax = (amount * tax_share) / tax_share_precesion;
uint256 swap_count = balanceOf(address(this));
if (swap_count > (2 * amount) / 3) swap_count = (2 * amount) / 3;
_swap_tokens_for_eth(swap_count, address(this));
if (tax > 0) {
if (game == address(0)) {
super._transfer(from, address(this), tax);
} else {
uint to_game = (tax * game_share) / tax_share_precesion;
uint to_token = tax - to_game;
if (to_game > 0) super._transfer(from, game, to_game);
if (to_token > 0)
super._transfer(from, address(this), to_token);
}
}
super._transfer(from, _pair, amount - tax);
}
receive() external payable {
uint256 game_count = (msg.value * game_share) / tax_share_precesion;
uint256 receiver_count = msg.value - game_count;
if (game == address(0)) {
game_count = 0;
receiver_count = msg.value;
}
if (game != address(0) && game_count > 0) {
(bool sentFee, ) = payable(game).call{value: game_count}("");
require(sentFee, "eth is not sent for game");
}
if (receiver != address(0) && receiver_count > 0) {
(bool sentFee, ) = payable(receiver).call{value: receiver_count}(
""
);
require(sentFee, "eth is not sent for receiver");
}
}
}
文件 4 的 10:IERC20.sol
pragma solidity ^0.8.20;
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);
}
文件 5 的 10:IERC20Metadata.sol
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 6 的 10:IUniswapV2Factory.sol
pragma solidity ^0.8.21;
interface IUniswapV2Factory {
function createPair(
address tokenA,
address tokenB
) external returns (address pair);
function getPair(
address tokenA,
address tokenB
) external view returns (address pair);
}
文件 7 的 10:IUniswapV2Router02.sol
pragma solidity ^0.8.21;
interface IUniswapV2Router02 {
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
function swapExactETHForTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
function getReserves(
address factory,
address tokenA,
address tokenB
) external view returns (uint reserveA, uint reserveB);
function getAmountsIn(
uint amountOut,
address[] memory path
) external view returns (uint[] memory amounts);
function getAmountsOut(
uint amountIn,
address[] memory path
) external view returns (uint[] memory amounts);
}
文件 8 的 10:Ownable.sol
pragma solidity ^0.8.23;
contract Ownable {
address _owner;
event RenounceOwnership();
constructor() {
_owner = msg.sender;
}
modifier onlyOwner() {
require(_owner == msg.sender, "only owner");
_;
}
function owner() external view virtual returns (address) {
return _owner;
}
function ownerRenounce() public onlyOwner {
_owner = address(0);
emit RenounceOwnership();
}
function transferOwnership(address newOwner) external onlyOwner {
_owner = newOwner;
}
}
文件 9 的 10:Token.sol
pragma solidity ^0.8.25;
import "./ERC20TokenBase.sol";
import "../lib/Ownable.sol";
import "../uniswap/IUniswapV2Router02.sol";
import "../uniswap/IUniswapV2Factory.sol";
address constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;
contract Token is ERC20TokenBase, Ownable {
uint8 constant DECIMALS = 9;
IUniswapV2Router02 public immutable router;
uint256 constant _startTotalSupply = 33333 * (10 ** DECIMALS);
uint256 constant _startMaxBuyCount = (_startTotalSupply * 5) / 10000;
uint256 constant _addMaxBuyPercentPerSec = 1;
uint256 constant _addMaxBuyPrecesion = 10000;
uint256 constant _taxPrecesion = 1000;
uint256 constant _transferZeroTaxSeconds = 1000;
address internal _pair;
address immutable _deployer;
bool internal _feeLocked;
uint256 internal _startTime;
constructor(
string memory name_,
string memory symbol_,
address router_addrress
) ERC20TokenBase(name_, symbol_) {
_deployer = msg.sender;
router = IUniswapV2Router02(router_addrress);
}
function pair_address() external view returns (address) {
return _pair;
}
modifier maxBuyLimit(uint256 amount) {
require(amount <= maxBuy(), "max buy");
_;
}
modifier lockFee() {
bool last_locked = _feeLocked;
_feeLocked = true;
_;
_feeLocked = last_locked;
}
function decimals() public pure override returns (uint8) {
return DECIMALS;
}
function is_token_started() public view returns (bool) {
return _startTime != 0;
}
function maxBuy() public view returns (uint256) {
if (!is_token_started()) return _startTotalSupply;
uint256 count = _startMaxBuyCount +
(_startTotalSupply *
(block.timestamp - _startTime) *
_addMaxBuyPercentPerSec) /
_addMaxBuyPrecesion;
if (count > _startTotalSupply) count = _startTotalSupply;
return count;
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
if (to == address(0) || to == DEAD_ADDRESS) {
transfer_internal(from, to, amount);
return;
}
if (
!is_token_started() &&
(from == address(0) ||
from == address(this) ||
from == _deployer ||
to == _deployer)
) {
super._transfer(from, to, amount);
return;
}
require(is_token_started(),"#1");
if (_feeLocked) {
super._transfer(from, to, amount);
return;
} else {
if (from == _pair) {
buy(to, amount);
return;
} else if (to == _pair) {
sell(from, amount);
return;
} else transfer_internal(from, to, amount);
}
}
function buy(
address to,
uint256 amount
) internal virtual maxBuyLimit(amount) lockFee {
super._transfer(_pair, to, amount);
}
function sell(address from, uint256 amount) internal virtual lockFee {
super._transfer(from, _pair, amount);
}
function transfer_internal(
address from,
address to,
uint256 amount
) internal virtual lockFee {
if (to == address(0) || to == DEAD_ADDRESS) {
_burn(from, amount);
return;
}
super._transfer(from, to, amount);
}
function make_pool() external payable onlyOwner {
_pair = IUniswapV2Factory(router.factory()).createPair(
address(this),
router.WETH()
);
_mint(address(this), _startTotalSupply);
_approve(address(this), address(router), type(uint256).max);
router.addLiquidityETH{value: msg.value}(
address(this),
_startTotalSupply,
0,
0,
msg.sender,
block.timestamp
);
_startTime = block.timestamp;
}
function _swap_tokens_for_eth(
uint256 tokenAmount,
address to
) internal lockFee {
if (tokenAmount == 0) return;
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = router.WETH();
router.swapExactTokensForETH(
tokenAmount,
0,
path,
to,
block.timestamp
);
}
}
文件 10 的 10:draft-IERC6093.sol
pragma solidity ^0.8.20;
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 IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"contracts/token/Geopolitics.sol": "Geopolitics"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"router_address","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"RenounceOwnership","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"game","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"game_share","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"is_token_started","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"make_pool","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"maxBuy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"max_tax_share","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ownerRenounce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pair_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"new_game_address","type":"address"}],"name":"set_game","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"new_game_share","type":"uint256"}],"name":"set_game_share","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"new_receiver","type":"address"}],"name":"set_receiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"new_tax_share","type":"uint256"}],"name":"set_tax_share","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tax_share","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tax_share_precesion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]