solidity-audit-ai / samples /safe /SafeToken.sol
LaelaZ's picture
Deploy Solidity Audit AI to HF Spaces (Docker)
31ea9b2 verified
raw
history blame contribute delete
565 Bytes
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
/// @title SafeToken
/// @notice Solidity >=0.8 checked arithmetic (reverts on overflow/underflow).
contract SafeToken {
mapping(address => uint256) public balanceOf;
constructor(uint256 initial) {
balanceOf[msg.sender] = initial;
}
// SAFE: 0.8 reverts on underflow/overflow automatically.
function transfer(address to, uint256 value) external {
require(to != address(0), "zero address");
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
}
}