59 lines
1.8 KiB
Solidity
59 lines
1.8 KiB
Solidity
//SPDX-License-Identifier: Unlicense
|
|
pragma solidity ^0.8.0;
|
|
|
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
|
contract Goflow is IERC20 {
|
|
uint256 public totalSupply;
|
|
mapping(address => uint256) public balanceOf;
|
|
mapping(address => mapping(address => uint256)) public allowance;
|
|
string public name = "Goflow";
|
|
string public symbol = "GOFLOW";
|
|
uint256 public decimals = 18;
|
|
|
|
function transfer(address recipient, uint256 amount)
|
|
external
|
|
returns (bool)
|
|
{
|
|
balanceOf[msg.sender] -= amount;
|
|
balanceOf[recipient] += amount;
|
|
emit Transfer(msg.sender, recipient, amount);
|
|
return true;
|
|
}
|
|
|
|
function approve(address spender, uint256 amount) external returns (bool) {
|
|
require(msg.sender != spender, "Cannot approve self");
|
|
require(
|
|
balanceOf[msg.sender] >= amount,
|
|
"insufficient balance for approval!"
|
|
);
|
|
allowance[msg.sender][spender] = amount;
|
|
emit Approval(msg.sender, spender, amount);
|
|
return true;
|
|
}
|
|
|
|
function transferFrom(
|
|
address sender,
|
|
address recipient,
|
|
uint256 amount
|
|
) external returns (bool) {
|
|
allowance[sender][msg.sender] -= amount;
|
|
balanceOf[sender] -= amount;
|
|
balanceOf[recipient] += amount;
|
|
emit Transfer(sender, recipient, amount);
|
|
return true;
|
|
}
|
|
|
|
function mint(uint256 amount) external {
|
|
balanceOf[msg.sender] += amount;
|
|
totalSupply += amount;
|
|
emit Transfer(address(0), msg.sender, amount);
|
|
}
|
|
|
|
function burn(uint256 amount) external {
|
|
balanceOf[msg.sender] -= amount;
|
|
totalSupply -= amount;
|
|
emit Transfer(msg.sender, address(0), amount);
|
|
}
|
|
}
|