Проверенный контрактТочноеMIT
LuluFactory
Адрес0xabeba4579054e7d862ed4e8242336ea9ec70e93b
- Баланс
0 ETH
- Транзакций
2
- Компилятор
solc 0.8.20
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.20+commit.a1b79de6
- Язык
- solidity
- Оптимизация
- Да, 200 прогонов
- Лицензия
- MIT
- Совпадение
- Точноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 426 426
- Транзакция создания
- 0xaf2eb75ffb…17c3d7c5cd
2134124.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract LuluToken {
string public name;
string public symbol;
uint8 public constant decimals = 0;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
uint256 private _locked = 1;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
modifier nonReentrant() {
require(_locked == 1, "ReentrancyGuard: reentered");
_locked = 2;
_;
_locked = 1;
}
constructor(string memory _name, string memory _symbol, address _deployer) {
name = _name;
symbol = _symbol;
uint256 supply = 1e36;
totalSupply = supply;
balanceOf[_deployer] = supply;
emit Transfer(address(0), _deployer, supply);
}
function transfer(address to, uint256 amount) external nonReentrant returns (bool) {
require(amount <= balanceOf[msg.sender], "Transfer amount exceeds balance");
balanceOf[msg.sender] -= amount;
unchecked {
balanceOf[to] += amount;
}
emit 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 nonReentrant returns (bool) {
uint256 allowed = allowance[from][msg.sender];
require(allowed >= amount, "Transfer amount exceeds allowance");
require(balanceOf[from] >= amount, "Transfer amount exceeds balance");
unchecked {
allowance[from][msg.sender] = allowed - amount;
}
balanceOf[from] -= amount;
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
function burn(uint256 amount) external nonReentrant {
require(amount > 0, "Burn amount is zero");
require(balanceOf[msg.sender] >= amount, "Burn amount exceeds balance");
unchecked {
balanceOf[msg.sender] -= amount;
}
totalSupply -= amount;
emit Transfer(msg.sender, address(0), amount);
}
function burnFrom(address from, uint256 amount) external nonReentrant {
require(amount > 0, "Burn amount is zero");
uint256 allowed = allowance[from][msg.sender];
require(allowed >= amount, "Burn amount exceeds allowance");
require(balanceOf[from] >= amount, "Burn amount exceeds balance");
unchecked {
allowance[from][msg.sender] = allowed - amount;
}
balanceOf[from] -= amount;
totalSupply -= amount;
emit Transfer(from, address(0), amount);
}
}
contract LuluFactory {
bytes private constant _TOKEN_NAME = "Lulu";
bytes private constant _TOKEN_SYMBOL = "LULU";
bytes private _tokenBytecode;
event TokenDeployed(address indexed tokenAddress, bytes32 salt);
constructor() {
_tokenBytecode = type(LuluToken).creationCode;
}
function deployToken(bytes32 salt) external returns (address tokenAddress) {
bytes memory initCode = abi.encodePacked(
_tokenBytecode,
abi.encode(_TOKEN_NAME, _TOKEN_SYMBOL, msg.sender)
);
bytes32 initCodeHash = keccak256(initCode);
tokenAddress = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
salt,
initCodeHash
)
)
)
)
);
assembly {
tokenAddress := create2(0, add(initCode, 0x20), mload(initCode), salt)
}
require(tokenAddress != address(0), "Factory: CREATE2 deployment failed");
emit TokenDeployed(tokenAddress, salt);
}
function predictTokenAddress(bytes32 salt) external view returns (address) {
bytes memory initCode = abi.encodePacked(
_tokenBytecode,
abi.encode(_TOKEN_NAME, _TOKEN_SYMBOL, msg.sender)
);
bytes32 initCodeHash = keccak256(initCode);
return address(
uint160(
uint256(
keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
salt,
initCodeHash
)
)
)
)
);
}
}Настройки компилятораПоказать
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.