i am trying to code a smart contract which takes the tokens of the player who enters.
function enterToken(address token, uint amount) public {
uint _amount = amount * 10 ** 18;
IERC20 token_ = IERC20(token);
require(token_.approve(address(this), _amount), 'Approve failed.');
require(token_.transferFrom(msg.sender, address(this), _amount), 'Transfer failed.');
I have literelly no clue why it is not working, maybe someone can help me out.
Thank you!