Approve and transfer token from inside a smart contract

Is it possible to approve spending ERC20 token and execute a smart contract function that would transfer approved token (in Moralis Unity SDK)?

So I’m looking to implement following game flow:

  • player authenticates in game (no problem)
  • player press starts game
  • call to game contract is initiated
    - game contract transfer ERC20 token from user to itself
  • once game is paid for game starts

From what I’ve seen so far

  • I could simply call ERC20 contract to send tokens
    or
  • I can send native token to game contract

But is it possible to send tokens to game contract and transfer it from there with
IERC20(gameToken).transferFrom(msg.sender, address(this), gameFee);
so that I don’t end up with a two step process of transferring tocken , waiting for confirmation and only then starting the game…

so that I don’t end up with a two step process of transferring tocken , waiting for confirmation and only then starting the game…

Are you saying you don’t want to wait for the transaction to be confirmed? This would be ideal if you want to make sure the user has paid for game entry.