Transfer tokens from contract balance to msg.sender

How do I transfer a token from a contract to a users wallet?

This transfers from the users wallet to a contract:

IERC20(utilityToken1Address).transferFrom(msg.sender, address(powerFeeAddress), powerFee);

How can I transfer from the contract balance to msg.sender?

IERC20(utilityToken1Address).transfer(msg.sender, token amount);
Edit : address(this).balance represents Ethereum balance in contract.

Will try this, thank you

This does not allow me to specify an amount of tokens, so I think you have presented a solution to transfer all token in the contract to a wallet and not an amount to the user?

instead of address(this).balance, you can just put the tokenamount

1 Like

You are correct I am not trying to transfer ERC/NATIVE token, I am trying to transfer an IERC20 token, address(this).balance will not work, and I am in doubt about the edited solution because how do I increase allowence from the contract to the external IERC20 token? Or is this not a problem?

function withdrawStuckTokens(address _token, uint256 _amount) public onlyOwner {
        IERC20(_token).transfer(msg.sender, _amount);
    }