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": {
"arabcoins.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
contract ArabCoins {\r
// ERC20 metadata\r
string public constant name = "ARABCOINS";\r
string public constant symbol = "ARBC";\r
uint8 public constant decimals = 18;\r
\r
// Supply / cap\r
uint256 public constant CAP = 1000000000 * 10**18; // 1,000,000,000\r
uint256 public totalSupply;\r
\r
// Ownership\r
address public owner;\r
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r
modifier onlyOwner(){ require(msg.sender == owner, "not owner"); _; }\r
\r
// ERC20 storage\r
mapping(address => uint256) private _balances;\r
mapping(address => mapping(address => uint256)) private _allowances;\r
\r
// ERC20 events\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
event Approval(address indexed owner, address indexed spender, uint256 value);\r
\r
constructor(){\r
owner = msg.sender;\r
emit OwnershipTransferred(address(0), msg.sender);\r
_mint(msg.sender, 100000 * 10**18); // initial 100,000 ARBC\r
}\r
\r
// Views\r
function balanceOf(address a) public view returns (uint256){ return _balances[a]; }\r
function allowance(address o, address s) public view returns (uint256){ return _allowances[o][s]; }\r
\r
// Transfers/approvals\r
function transfer(address to, uint256 amt) public returns (bool){ _transfer(msg.sender, to, amt); return true; }\r
function approve(address s, uint256 amt) public returns (bool){ _approve(msg.sender, s, amt); return true; }\r
function transferFrom(address f, address t, uint256 amt) public returns (bool){\r
uint256 al = _allowances[f][msg.sender];\r
require(al >= amt, "insufficient allowance");\r
unchecked { _approve(f, msg.sender, al - amt); }\r
_transfer(f, t, amt);\r
return true;\r
}\r
\r
// Mint (owner only) with hard cap\r
function mint(address to, uint256 amt) external onlyOwner { _mint(to, amt); }\r
\r
// Ownership\r
function transferOwnership(address n) external onlyOwner {\r
require(n != address(0), "zero addr");\r
emit OwnershipTransferred(owner, n);\r
owner = n;\r
}\r
\r
// Internals\r
function _transfer(address f, address t, uint256 amt) internal {\r
require(t != address(0), "transfer to zero");\r
uint256 fb = _balances[f];\r
require(fb >= amt, "balance too low");\r
unchecked { _balances[f] = fb - amt; }\r
_balances[t] += amt;\r
emit Transfer(f, t, amt);\r
}\r
\r
function _approve(address o, address s, uint256 amt) internal {\r
require(s != address(0), "approve to zero");\r
_allowances[o][s] = amt;\r
emit Approval(o, s, amt);\r
}\r
\r
function _mint(address to, uint256 amt) internal {\r
require(to != address(0), "mint to zero");\r
uint256 ns = totalSupply + amt;\r
require(ns <= CAP, "cap exceeded");\r
totalSupply = ns;\r
_balances[to] += amt;\r
emit Transfer(address(0), to, amt);\r
}\r
}\r
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": [],
"evmVersion": "london"
}
}}
Submitted on: 2025-11-01 10:55:22
Comments
Log in to comment.
No comments yet.