Assuming the following super simple code, how can I withdraw ERC20 tokens that are owned by a gnosis safe to my contract?

I set up a spending limit in my gnosis safe allowing the bellow contract to withdraw tokens (USDC) however, this fails as whilst the limit is set in gnosis safe and the contract is allowed to withdraw, in actuality no allowance exists on the USDC contract to withdraw from the gnosis safe wallet.

from vyper.interfaces import ERC20

admin: address 

def __init__():
    self.admin = msg.sender

def deposit(tokenIn: address, amountIn: uint256):
  ERC20(tokenIn).transferFrom(msg.sender, self, amountIn)

1 Answer 1


You need to set the allowance on the USDC contract itself and approve your deposit contract address as spender.

And then initiate the deposit transaction to the contract.

It goes something like this:

  1. In Safe, use the transaction builder (right in the UI).
  2. In the address in the tx builder, provide the USDC contract address. It should load the ABI automatically.
  3. Select approve. In spender, provide the address of your deposit contract (your Vyper example), and in rawAmount how much USDC you are going to deposit.

Once you get this transaction out, do the deposit transaction in a similar way:

  1. Start the tx builder in Safe.
  2. Provide the deposit contract address & paste in the ABI.
  3. In tokenIn, provide the USDC address and in amountIn.

This will work and deposit from Safe into the contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.