Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract XDEX {
string public name = "XDEX";
string public symbol = "XDX";
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor() {
uint256 initial = 1_000_000 * 10**uint256(decimals);
totalSupply = initial;
balanceOf[msg.sender] = initial; // mint to deployer
emit Transfer(address(0), msg.sender, initial);
}
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0), "zero addr");
uint256 bal = balanceOf[from];
require(bal >= value, "insufficient");
unchecked { balanceOf[from] = bal - value; }
balanceOf[to] += value;
emit Transfer(from, to, value);
}
function transfer(address to, uint256 value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) external returns (bool) {
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) external returns (bool) {
uint256 allowed = allowance[from][msg.sender];
require(allowed >= value, "allowance");
unchecked { allowance[from][msg.sender] = allowed - value; }
_transfer(from, to, value);
return true;
}
// Ownerless mint for demo/testing; REMOVE or restrict before mainnet
function mint(address to, uint256 amount) external {
totalSupply += amount;
balanceOf[to] += amount;
emit Transfer(address(0), to, amount);
}
}
Submitted on: 2025-10-04 15:29:47
Comments
Log in to comment.
No comments yet.