RWA913MToken

Description:

ERC20 token contract with Mintable, Factory capabilities. Standard implementation for fungible tokens on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/RWA913MToken.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
/// @title RWA913M (ERC20 with Treasury Hashes)\r
/// @notice ERC20 token, owner-only mintable, initial supply 913,000,000 to deployer.\r
/// @dev Single-file, no external imports. Ethereum / EVM compatible.\r
contract RWA913MToken {\r
    /***************************************************************\r
                                EVENTS\r
    ***************************************************************/\r
    event Transfer(address indexed from, address indexed to, uint256 value);\r
    event Approval(address indexed owner, address indexed spender, uint256 value);\r
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r
\r
    // Treasury Hash events\r
    event TreasuryHashAdded(uint256 indexed index, bytes32 indexed hash, address indexed by);\r
    event TreasuryHashUpdated(uint256 indexed index, bytes32 oldHash, bytes32 newHash, address indexed by);\r
    event TreasuryHashRemoved(uint256 indexed index, bytes32 removedHash, address indexed by);\r
\r
    /***************************************************************\r
                             ERC20 STORAGE\r
    ***************************************************************/\r
    string public constant name = "RWA913MToken";\r
    string public constant symbol = "RWA913MToken";\r
    uint8  public constant decimals = 18;\r
\r
    uint256 private _totalSupply;\r
    mapping(address => uint256) private _balances;\r
    mapping(address => mapping(address => uint256)) private _allowances;\r
\r
    /***************************************************************\r
                               OWNERSHIP\r
    ***************************************************************/\r
    address private _owner;\r
\r
    modifier onlyOwner() {\r
        require(msg.sender == _owner, "Ownable: caller is not the owner");\r
        _;\r
    }\r
\r
    function owner() public view returns (address) {\r
        return _owner;\r
    }\r
\r
    /***************************************************************\r
                           TREASURY HASH STORAGE\r
    ***************************************************************/\r
    // Store Ethereum-style hashes (e.g., tx hashes) as bytes32\r
    bytes32[] private _treasuryHashes;\r
\r
    /***************************************************************\r
                              CONSTRUCTOR\r
    ***************************************************************/\r
    constructor() {\r
        _owner = msg.sender;\r
        emit OwnershipTransferred(address(0), msg.sender);\r
\r
        // Initial supply: 913,000,000 * 10^18 minted to deployer\r
        uint256 initialSupply = 913_000_000 * (10 ** uint256(decimals));\r
        _mint(msg.sender, initialSupply);\r
    }\r
\r
    /***************************************************************\r
                               ERC20 LOGIC\r
    ***************************************************************/\r
    function totalSupply() external view returns (uint256) {\r
        return _totalSupply;\r
    }\r
\r
    function balanceOf(address account) external view returns (uint256) {\r
        return _balances[account];\r
    }\r
\r
    function allowance(address tokenOwner, address spender) external view returns (uint256) {\r
        return _allowances[tokenOwner][spender];\r
    }\r
\r
    function transfer(address to, uint256 amount) external returns (bool) {\r
        _transfer(msg.sender, to, amount);\r
        return true;\r
    }\r
\r
    function approve(address spender, uint256 amount) external returns (bool) {\r
        _approve(msg.sender, spender, amount);\r
        return true;\r
    }\r
\r
    function transferFrom(address from, address to, uint256 amount) external returns (bool) {\r
        uint256 currentAllowance = _allowances[from][msg.sender];\r
        require(currentAllowance >= amount, "ERC20: insufficient allowance");\r
        unchecked {\r
            _approve(from, msg.sender, currentAllowance - amount);\r
        }\r
        _transfer(from, to, amount);\r
        return true;\r
    }\r
\r
    /***************************************************************\r
                           OWNER-ONLY MINT\r
    ***************************************************************/\r
    /// @notice Mints `amount` tokens to `to`. Only owner.\r
    /// @dev No cap (as requested). Add a cap guard if you want a maximum supply.\r
    function mint(address to, uint256 amount) external onlyOwner returns (bool) {\r
        _mint(to, amount);\r
        return true;\r
    }\r
\r
    /***************************************************************\r
                        OPTIONAL OWNERSHIP UTILS\r
    ***************************************************************/\r
    function transferOwnership(address newOwner) external onlyOwner {\r
        require(newOwner != address(0), "Ownable: new owner is zero address");\r
        emit OwnershipTransferred(_owner, newOwner);\r
        _owner = newOwner;\r
    }\r
\r
    function renounceOwnership() external onlyOwner {\r
        emit OwnershipTransferred(_owner, address(0));\r
        _owner = address(0);\r
    }\r
\r
    /***************************************************************\r
                        TREASURY HASHES MANAGEMENT\r
    ***************************************************************/\r
    /// @notice Add a single treasury hash (e.g., an Ethereum tx hash).\r
    /// @param h The bytes32 hash value (use bytes32, e.g., 0xabc...).\r
    /// @return index The index where the hash was stored.\r
    function addTreasuryHash(bytes32 h) external onlyOwner returns (uint256 index) {\r
        _treasuryHashes.push(h);\r
        index = _treasuryHashes.length - 1;\r
        emit TreasuryHashAdded(index, h, msg.sender);\r
    }\r
\r
    /// @notice Add multiple treasury hashes in one transaction.\r
    function addTreasuryHashes(bytes32[] calldata hashes) external onlyOwner {\r
        for (uint256 i = 0; i < hashes.length; i++) {\r
            _treasuryHashes.push(hashes[i]);\r
            emit TreasuryHashAdded(_treasuryHashes.length - 1, hashes[i], msg.sender);\r
        }\r
    }\r
\r
    /// @notice Update a treasury hash at `index`.\r
    function updateTreasuryHash(uint256 index, bytes32 newHash) external onlyOwner {\r
        require(index < _treasuryHashes.length, "Treasury: index out of bounds");\r
        bytes32 old = _treasuryHashes[index];\r
        _treasuryHashes[index] = newHash;\r
        emit TreasuryHashUpdated(index, old, newHash, msg.sender);\r
    }\r
\r
    /// @notice Remove a treasury hash by index (swap & pop).\r
    function removeTreasuryHash(uint256 index) external onlyOwner {\r
        require(index < _treasuryHashes.length, "Treasury: index out of bounds");\r
        uint256 last = _treasuryHashes.length - 1;\r
        bytes32 removed = _treasuryHashes[index];\r
\r
        if (index != last) {\r
            _treasuryHashes[index] = _treasuryHashes[last];\r
        }\r
        _treasuryHashes.pop();\r
\r
        emit TreasuryHashRemoved(index, removed, msg.sender);\r
    }\r
\r
    /// @notice Get the number of stored treasury hashes.\r
    function treasuryHashesCount() external view returns (uint256) {\r
        return _treasuryHashes.length;\r
    }\r
\r
    /// @notice Read a specific treasury hash by index.\r
    function treasuryHashAt(uint256 index) external view returns (bytes32) {\r
        require(index < _treasuryHashes.length, "Treasury: index out of bounds");\r
        return _treasuryHashes[index];\r
    }\r
\r
    /// @notice Return all treasury hashes (use cautiously if the list grows large).\r
    function treasuryHashes() external view returns (bytes32[] memory) {\r
        return _treasuryHashes;\r
    }\r
      \r
    /***************************************************************\r
                          INTERNAL ERC20 HELPERS\r
    ***************************************************************/\r
    function _transfer(address from, address to, uint256 amount) internal {\r
        require(from != address(0), "ERC20: transfer from zero address");\r
        require(to != address(0), "ERC20: transfer to zero address");\r
\r
        uint256 fromBal = _balances[from];\r
        require(fromBal >= amount, "ERC20: transfer amount exceeds balance");\r
        unchecked {\r
            _balances[from] = fromBal - amount;\r
        }\r
        _balances[to] += amount;\r
\r
        emit Transfer(from, to, amount);\r
    }\r
\r
    function _approve(address tokenOwner, address spender, uint256 amount) internal {\r
        require(tokenOwner != address(0), "ERC20: approve from zero address");\r
        require(spender != address(0), "ERC20: approve to zero address");\r
\r
        _allowances[tokenOwner][spender] = amount;\r
        emit Approval(tokenOwner, spender, amount);\r
    }\r
\r
    function _mint(address to, uint256 amount) internal {\r
        require(to != address(0), "ERC20: mint to zero address");\r
        _totalSupply += amount;\r
        _balances[to] += amount;\r
        emit Transfer(address(0), to, amount);\r
    }\r
}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "evmVersion": "paris",
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    }
  }
}}

Tags:
ERC20, Token, Mintable, Factory|addr:0x1f5494d5bfefd49d5f9325b2e7be8114039f0659|verified:true|block:23661082|tx:0x03f97551fdf978a1013160de8c5f4a1db893b3160ed130bd0b92c541c4f008f6|first_check:1761480290

Submitted on: 2025-10-26 13:04:51

Comments

Log in to comment.

No comments yet.