Ivan or Filip mentioned this slightly in the course but I would like to know the solution (or walkaround).
The problem with the current contract is that literally anyone can mint the token without needing to play the game.
contract GameToken is ERC20 {
constructor(
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) {
}
function mint(address _to, uint256 _value) external returns(bool){
_mint(_to, _value);
return true;
}
}
I would like to know how to make it so that the user only gets (mint) the token when he/she actually played the game.
One solution is to make the mint function callable only by the owner. However, the owner will have to constantly monitor the game, and the owner will have to pay the gas to transfer the token to the user.
Any idea on how to mint GameToken properly?