Hey,
I would like to create smart contract where You can mint new tokens (accesible by anyone calling) and charge a fee during that mint payable to contract creator. Something like a donation, but with the mint new tokens function at the same time.
I came up with something like this (changed onlyOwner to paybale), but how to set I believe msg.value to call a specific amount to pay during the mint. I would appreciate every answer as Im struggling with that for hours now … thank You.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, Ownable {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 10000 * 10 ** decimals());
}
function mint(address to, uint256 amount) public payble {
_mint(to, amount);
}
}