How to use approve function of dai with gsn support

hello everyone.
How can i use approve function of dai with gsn support ?

What exactly you trying to achieve?

i want to support gas of approve function that is calling by user in approve and transferFrom pattern.(i support transferFrom with gsn but i can’t support gas of approve function using gsn)

IIRC, you’re trying to create “GSN-aware” token, that accepts requests via GSN
So you need the paymaster to accept every request that is valid for this token
(e.g. if I call transfer(), it should accept it, as long as I really own the tokens.)

the simplest way to achieve that is have this code in your preRelayedCall:

function preRelayedCall(...) {
  require( == myToken, "not a call to my token");
  return ("", true);

This paymaster will accept any valid token operation (approve, transfer, transferFrom, etc), and will reject (not agree to pay) any invalid operation (transfer without balance, transferFrom without approval, and any invalid method signature)

The important part is the true value in the return.
It means “as a paymaster, I fully trust this destination to verify the request. I will accept the request if the called function doesn’t revert”

You should specify “true” in this field only if you know the destination address (as we check it in the require just before)
There is a “trust” issue here (and this is why this “true” value is not the default): If the destination address wastes a lot of gas (above 100kgas) before reverting, the paymaster STILL pays for this reverted transaction.
This is OK if you own the destination contract, and knows that it never wastes too much gas while checking and reverting (e.g. it doesn’t use “assert()”, which uses all gas. revert() and require() are OK)