70 lines
1.9 KiB
Solidity
70 lines
1.9 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity 0.8.28;
|
|
|
|
contract Kanel42_token {
|
|
string public name = "Kanel42";
|
|
string public symbol = "KNL42";
|
|
uint8 public decimals = 6;
|
|
uint256 public totalSupply = 8000000000; // 8000
|
|
uint256 public totalMinted;
|
|
uint256 public mintCost = 0.01 ether;
|
|
mapping(address => uint256) public balanceOf;
|
|
mapping(address => mapping(address => uint256)) public allowance;
|
|
|
|
function transfer(address _to, uint256 _value)
|
|
public
|
|
returns (bool success)
|
|
{
|
|
balanceOf[msg.sender] -= _value;
|
|
balanceOf[_to] += _value;
|
|
emit Transfer(msg.sender, _to, _value);
|
|
success = true;
|
|
}
|
|
|
|
function transferFrom(address _from, address _to, uint256 _value)
|
|
public
|
|
returns (bool success)
|
|
{
|
|
allowance[_from][msg.sender] -= _value;
|
|
balanceOf[_from] -= _value;
|
|
balanceOf[_to] += _value;
|
|
emit Transfer(_from, _to, _value);
|
|
success = true;
|
|
}
|
|
|
|
function approve(address _spender, uint256 _value)
|
|
public
|
|
returns (bool success)
|
|
{
|
|
allowance[msg.sender][_spender] = _value;
|
|
emit Approval(msg.sender, _spender, _value);
|
|
success = true;
|
|
}
|
|
|
|
function mint() public payable {
|
|
uint256 minted = msg.value / mintCost * (10 ** decimals);
|
|
|
|
balanceOf[msg.sender] += minted;
|
|
totalMinted += minted;
|
|
|
|
emit Transfer(address(0), msg.sender, minted);
|
|
}
|
|
|
|
function burn(uint256 _value) public {
|
|
uint256 sendBack = _value / (10 ** decimals) * mintCost * 1 ether;
|
|
|
|
balanceOf[msg.sender] -= _value;
|
|
totalMinted -= _value;
|
|
|
|
msg.sender.call{ value: sendBack };
|
|
|
|
emit Transfer(msg.sender, address(0), _value);
|
|
}
|
|
|
|
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
|
event Approval(
|
|
address indexed _owner, address indexed _spender, uint256 _value
|
|
);
|
|
}
|