// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.13;
import "./interfaces/IBaseXToken.sol";
contract BaseXToken is IBaseXToken {
string public constant name = "BaseX Token";
string public constant symbol = "BXT";
uint8 public constant decimals = 18;
uint public totalSupply = 0;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bool public initialMinted;
address public minter;
address public redemptionReceiver;
address public merkleClaim;
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
constructor() {
minter = msg.sender;
_mint(msg.sender, 0);
}
// No checks as its meant to be once off to set minting rights to BaseV1 Minter
function setMinter(address _minter) external {
require(msg.sender == minter);
minter = _minter;
}
// Initial mint: total 50M
function initialMint(address _recipient) external {
require(msg.sender == minter && !initialMinted);
initialMinted = true;
_mint(_recipient, 50 * 1e6 * 1e18);
}
function approve(address _spender, uint _value) external returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function _mint(address _to, uint _amount) internal returns (bool) {
totalSupply += _amount;
unchecked {
balanceOf[_to] += _amount;
}
emit Transfer(address(0x0), _to, _amount);
return true;
}
function _transfer(address _from, address _to, uint _value) internal returns (bool) {
balanceOf[_from] -= _value;
unchecked {
balanceOf[_to] += _value;
}
emit Transfer(_from, _to, _value);
return true;
}
function transfer(address _to, uint _value) external returns (bool) {
return _transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) external returns (bool) {
uint allowed_from = allowance[_from][msg.sender];
if (allowed_from != type(uint).max) {
allowance[_from][msg.sender] -= _value;
}
return _transfer(_from, _to, _value);
}
function mint(address account, uint amount) external returns (bool) {
require(msg.sender == minter, 'not allowed');
_mint(account, amount);
return true;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IBaseXToken {
function totalSupply() external view returns (uint);
function balanceOf(address) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address, uint) external returns (bool);
function transferFrom(address,address,uint) external returns (bool);
function mint(address, uint) external returns (bool);
function minter() external returns (address);
}
{
"compilationTarget": {
"contracts/BaseXToken.sol": "BaseXToken"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"initialMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialMinted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleClaim","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redemptionReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"setMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]