Проверенный контрактЧастичноеMIT
HiveToken
Адрес0xab40efbaff5a67ec3e273b746ae7bac7d1bc4ae3
- Баланс
0 ETH
- Транзакций
306
- Компилятор
solc 0.8.26
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.26+commit.8a97fa7a
- Язык
- solidity
- Оптимизация
- Да, 800 прогонов
- Версия EVM
- cancun
- Через IR
- да
- Лицензия
- MIT
- Совпадение
- Частичноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 179 438
- Транзакция создания
- 0xac2c134fdc…e176c5302f
2 файла
- src/HiveToken.solглавный4,36 КБ
- lib/solmate/src/tokens/ERC20.sol6,81 КБ
src/HiveToken.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {ERC20} from "solmate/src/tokens/ERC20.sol";
/// @title HiveToken ($HIVE)
/// @notice Fixed-supply ERC-20. The whole launch supply is minted once, in the constructor, to the colony treasury,
/// which seeds it into the canonical Uniswap v4 pool. There is no owner, no mint function, no transfer tax,
/// no blocklist and no pause. Anyone may burn their own tokens; burns reduce `totalSupply` but never change
/// `LAUNCH_SUPPLY`, the fixed denominator used by every supply-based trading limit.
contract HiveToken is ERC20 {
/// @notice Immutable launch supply, 1,000,000,000 HIVE. Denominator for every percentage-of-supply trade limit.
uint256 public constant LAUNCH_SUPPLY = 1_000_000_000e18;
string private _description;
string private _website;
string private _image;
string private _x;
error ZeroRecipient();
/// @dev metadata strings are joined into JSON as they are, so they may not contain `"`, `\` or control characters
error UnsafeMetadata();
constructor(
string memory name_,
string memory symbol_,
address supplyRecipient,
string memory description_,
string memory website_,
string memory image_,
string memory x_
) ERC20(name_, symbol_, 18) {
if (supplyRecipient == address(0)) revert ZeroRecipient();
_requireJsonSafe(name_);
_requireJsonSafe(symbol_);
_requireJsonSafe(description_);
_requireJsonSafe(website_);
_requireJsonSafe(image_);
_requireJsonSafe(x_);
_description = description_;
_website = website_;
_image = image_;
_x = x_;
_mint(supplyRecipient, LAUNCH_SUPPLY);
}
/// @notice Burns `amount` of the caller's tokens.
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
/// @notice Presentation metadata read by Programmable and terminals: (description, website, image, extraData).
function metadata()
external
view
returns (string memory description, string memory website, string memory image, bytes memory extraData)
{
return (_description, _website, _image, "");
}
/// @notice The same presentation metadata plus the X profile, as inline JSON
/// (`data:application/json;base64,…`): name, symbol, description, image, website / external_url, x / twitter.
/// Empty fields are left out.
function tokenURI() external view returns (string memory) {
bytes memory json = abi.encodePacked(
'{"name":"',
name,
'","symbol":"',
symbol,
'"',
_field("description", _description),
_field("image", _image),
_field("website", _website),
_field("external_url", _website),
_field("x", _x),
_field("twitter", _x),
"}"
);
return string(abi.encodePacked("data:application/json;base64,", _base64(json)));
}
function _field(string memory key, string memory value) private pure returns (bytes memory) {
return bytes(value).length == 0 ? bytes("") : abi.encodePacked(',"', key, '":"', value, '"');
}
function _requireJsonSafe(string memory s) private pure {
bytes memory b = bytes(s);
for (uint256 i; i < b.length; ++i) {
if (b[i] == '"' || b[i] == "\\" || uint8(b[i]) < 0x20) revert UnsafeMetadata();
}
}
function _base64(bytes memory data) private pure returns (string memory) {
bytes memory table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
uint256 len = data.length;
bytes memory out = new bytes(4 * ((len + 2) / 3));
uint256 j;
for (uint256 i; i < len; i += 3) {
uint256 n = uint256(uint8(data[i])) << 16;
if (i + 1 < len) n |= uint256(uint8(data[i + 1])) << 8;
if (i + 2 < len) n |= uint256(uint8(data[i + 2]));
out[j++] = table[(n >> 18) & 63];
out[j++] = table[(n >> 12) & 63];
out[j++] = i + 1 < len ? table[(n >> 6) & 63] : bytes1("=");
out[j++] = i + 2 < len ? table[n & 63] : bytes1("=");
}
return string(out);
}
}
lib/solmate/src/tokens/ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual 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) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
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]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
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");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
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) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : 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)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}
Настройки компилятораПоказать
{
"viaIR": true,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none"
},
"libraries": {},
"optimizer": {
"runs": 800,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"v4-core/=lib/v4-core/",
"@uniswap/v4-core/=lib/v4-core/",
"v4-periphery/=lib/v4-periphery/",
"solmate/=lib/solmate/"
]
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.