-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; | ||
|
||
contract NexusToken is ERC20 { | ||
address private _owner; | ||
uint256 private _totalSupply; | ||
|
||
constructor() public { | ||
_owner = msg.sender; | ||
_totalSupply = 1000000 * (10 ** 18); // 1 million tokens with 18 decimals | ||
_mint(_owner, _totalSupply); | ||
} | ||
|
||
function transfer(address recipient, uint256 amount) public override { | ||
require(recipient != address(0), "Cannot transfer to zero address"); | ||
_transfer(msg.sender, recipient, amount); | ||
} | ||
|
||
function _transfer(address sender, address recipient, uint256 amount) internal { | ||
require(sender != address(0), "Cannot transfer from zero address"); | ||
require(recipient != address(0), "Cannot transfer to zero address"); | ||
_balances[sender] = _balances[sender].sub(amount, "Insufficient balance"); | ||
_balances[recipient] = _balances[recipient].add(amount); | ||
emit Transfer(sender, recipient, amount); | ||
} | ||
} |