Description:
ERC20 token contract with Mintable, Burnable capabilities. Standard implementation for fungible tokens on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract NDARQ {
string public name = "NDARQ";
string public symbol = "NDARQ";
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 the owner");
_;
}
constructor() {
owner = msg.sender;
_mint(msg.sender, 100000000 * (10 ** uint256(decimals))); // 100,000,000 tokens
}
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
function transfer(address to, uint256 amount) public returns (bool) {
require(to != address(0), "Invalid address");
require(balances[msg.sender] >= amount, "Not enough balance");
balances[msg.sender] -= amount;
balances[to] += amount;
emit Transfer(msg.sender, to, amount);
return true;
}
function approve(address spender, uint256 amount) public returns (bool) {
allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function allowance(address accountOwner, address spender) public view returns (uint256) {
return allowances[accountOwner][spender];
}
function transferFrom(address from, address to, uint256 amount) public returns (bool) {
require(to != address(0), "Invalid address");
require(balances[from] >= amount, "Not enough balance");
require(allowances[from][msg.sender] >= amount, "Allowance exceeded");
balances[from] -= amount;
balances[to] += amount;
allowances[from][msg.sender] -= amount;
emit Transfer(from, to, amount);
return true;
}
// Owner can mint more tokens
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
// Owner can burn tokens from any account
function burn(address from, uint256 amount) public onlyOwner {
require(balances[from] >= amount, "Not enough balance");
balances[from] -= amount;
totalSupply -= amount;
emit Transfer(from, address(0), amount);
}
// Internal mint function
function _mint(address to, uint256 amount) internal {
require(to != address(0), "Invalid address");
totalSupply += amount;
balances[to] += amount;
emit Transfer(address(0), to, amount);
}
}
Submitted on: 2025-09-24 20:10:27
Comments
Log in to comment.
No comments yet.