Проверенный контрактТочноеMIT
CryptoCityCoin
Адрес0x5cafd1e5a02db267cf6ceeabda990c577677e0ca
- Баланс
0 ETH
- Транзакций
1
- Компилятор
solc 0.8.34
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.34+commit.80d5c536
- Язык
- solidity
- Оптимизация
- Нет
- Лицензия
- MIT
- Совпадение
- Точноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 412 100
- Транзакция создания
- 0xdca2e535dc…e39aba9624
contracts/cc.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract CryptoCityCoin {
string public name = "CryptoCity Coin";
string public symbol = "CC";
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
address public owner;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
constructor(uint256 initialSupply) {
owner = msg.sender;
_mint(msg.sender, initialSupply);
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
function allowance(address _owner, address spender) public view returns (uint256) {
return _allowances[_owner][spender];
}
function approve(address spender, uint256 amount) public returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public returns (bool) {
uint256 currentAllowance = _allowances[from][msg.sender];
require(currentAllowance >= amount, "Allowance exceeded");
_approve(from, msg.sender, currentAllowance - amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
uint256 currentAllowance = _allowances[msg.sender][spender];
require(currentAllowance >= subtractedValue, "Decreased below zero");
_approve(msg.sender, spender, currentAllowance - subtractedValue);
return true;
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function _transfer(address from, address to, uint256 amount) internal {
require(to != address(0), "Transfer to zero address");
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "Balance too low");
_balances[from] = fromBalance - amount;
_balances[to] += amount;
emit Transfer(from, to, amount);
}
function _mint(address to, uint256 amount) internal {
require(to != address(0), "Mint to zero address");
totalSupply += amount;
_balances[to] += amount;
emit Transfer(address(0), to, amount);
}
function _approve(address _owner, address spender, uint256 amount) internal {
require(spender != address(0), "Approve to zero address");
_allowances[_owner][spender] = amount;
emit Approval(_owner, spender, amount);
}
}Настройки компилятораПоказать
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.