Verified contractExactMIT
WEH
Address0x543d110a0bac69851bc8dcfde8ae62d1ecc9f88d
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,462,503
- Creation transaction
- 0xe877f14bbd…d41a54ca8a
src/WEH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title WEH
/// @notice Minimal standard ERC-20 with an owner-only mint function.
contract WEH {
string public constant name = "WEH";
string public constant symbol = "WEH";
uint8 public constant decimals = 18;
uint256 public totalSupply;
address public owner;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
error NotOwner();
error ZeroAddress();
error InsufficientBalance();
error InsufficientAllowance();
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
constructor(uint256 initialSupply) {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
if (initialSupply != 0) {
_mint(msg.sender, initialSupply);
}
}
function transfer(address to, uint256 amount) external returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
function approve(address spender, uint256 amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) external returns (bool) {
uint256 allowed = allowance[from][msg.sender];
if (allowed != type(uint256).max) {
if (allowed < amount) revert InsufficientAllowance();
unchecked {
allowance[from][msg.sender] = allowed - amount;
}
emit Approval(from, msg.sender, allowed - amount);
}
_transfer(from, to, amount);
return true;
}
function mint(address to, uint256 amount) external onlyOwner {
_mint(to, amount);
}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert ZeroAddress();
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function _transfer(address from, address to, uint256 amount) internal {
if (to == address(0)) revert ZeroAddress();
uint256 fromBalance = balanceOf[from];
if (fromBalance < amount) revert InsufficientBalance();
unchecked {
balanceOf[from] = fromBalance - amount;
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
}
function _mint(address to, uint256 amount) internal {
if (to == address(0)) revert ZeroAddress();
totalSupply += amount;
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.