Smart Contract Wallets Multisignature – Can a Smart Contract Approve a Pending Transaction on a Multisig Wallet?

erc-20-approvegnosis-safemultisignaturesmart-contract-wallets

Suppose I have a multisig wallet like a Gnosis Safe, which requires (say) two or three signers to approve any given transaction. In other words, the multisig wallet has its own wallet address, and 2 or 3 other wallet addresses must approve any transaction that is made.

What I want is for one of these "other" wallets to actually be a smart contract. There will be an owner of that contract who of course launches the contract and puts it into an active state. In the active state, it automatically approves any transaction that is launched by the other wallet owner for this multisig wallet. The smart contract also has a function where the contract owner can take it out of the active state so that no transactions are approved.

The flow would be as follows: Let's say we have a multisig wallet (eg Gnosis Safe) with two owners: 1. "John" and 2. "Smart Contract". John decides to send 1 Eth to another wallet, so John uses his Metamask, which is connected to the Gnosis Safe multisig wallet, to create and sign this transaction. Next, John uses some other pieces of software (say a simple web3 script in Javascript or python) that calls a function in Smart Contract requesting approval for this transaction. Smart Contract verifies that the request is from John and verifies that Smart Contract is in the active state. So, it gets the transaction and signs it. Now the transaction has gone through.

If the owner of Smart Contract ever decides that they don't want John making any more transactions then they can set the contract into the inactive state, and now John cannot make any more transactions.

Is this possible in a smart contract? For the function that John calls to request an approval, how is the transaction information passed, or is there some other way that Smart Contract can use to get access to this pending transaction? How can Smart Contract approve this transaction?

Finally, suppose I want to have this capability of the Eth, BSC, Avax and Polygon chains. I assume this means I have to have a version of this smart contract running on each of these chains?

Yes I have a good reason for asking if this is possible. It has to do with regulatory and taxation issues.

Best Answer

I can only answer very specific to the Safe, as this highly depends on the smart contract wallet.

With the Safe there are 2 possible approaches.

Starting with version 1.3.0 of the Safe it is possible to add a Guard. This guard could be controlled to prevent any transactions while it is in the "inactive" state.

Another solution would be to implement EIP-1271 (the legacy version) on a contract that controls the active or inactive state. That contract would revert when isValidSignature is called in the inactive state and the expected value otherwise.

Here an example how this can be done either with the Guard approach or with EIP-1271 signatures: https://gist.github.com/rmeissner/26bae7deaac62db764abc9a03902094e

Related Topic