Gnosis Safe TokenPaymaster example

I would like to use GSN to execute gnosis safe transactions and pay gas with ERC20 tokens from the same gnosis safe account. I’m not able to find any examples of this online. Any help or pointers would be appreciated. Thanks.

I think the closest example for doing something similar would be this:


In this example an externally-owned address signs a ‘permit’ method and then paymaster pulls ERC-20 tokens from that address, and swaps them into ETH. It does not work for tokens that do not implement a ‘permit’ method.

As the Gnosis Safe cannot sign the ‘permit’, I think it will have to give an approval to the Paymaster to spend tokens in a transaction that is paid for in ether.

There is also a sample Paymaster that uses a proxy contract that gives an approval inside its constructor, so the proxy deployment can be paid via GSN as well. This will require sending the ERC-20 tokens to the address that does not have a code deployed yet, calculating that address with a CREATE2.

We did not take this concept of deploying a proxy contract to be production-ready, but it does demonstrate the concept and should be possible to make it work with Gnosis Safe proxy.