2

I'm trying to support Argent wallet signing (contract wallet / compatible EIP-1271) through Wallet-Connect.

Let's say I have a Gnosis-Safe with the following setup: (owners: [argent-contract-addr], threshold: 1).

I'm able to obtain a signature of my transaction's txhash from Argent via Wallet-Connect, but this signature is signed by argent-eoa-addr controlling argent-contract-addr. Given Gnosis-Safe is compatible with EIP-1271 as well as Argent wallet that provides isValidSignature, it should be possible.

How can adjust this signature to be understood by the Safe as a contract signature? From the safe's code, it looks like I should modify v -> 0x00 but it seems that's not just it when I look at the contract code.

enter image description here

I'm also trying to understand this test but it's not yet clear. Is there any documentation on how to build contract signatures compatible with Safe?

4
  • What problems do you run into when adjusting V in argent's signature?
    – mikheevm
    Commented Mar 4, 2022 at 14:41
  • Invalid owner provided Commented Mar 4, 2022 at 14:47
  • Check docs.gnosis-safe.io/contracts/…, but you might still run into issues with eip1271, as the Safe contract uses the a legacy version
    – Richard
    Commented Mar 4, 2022 at 16:25
  • Thanks @Richard, I will give a try Commented Mar 4, 2022 at 16:51

1 Answer 1

4

To encode an EIP-1271 signature you would take the data returned by your signature function (for Argent this should be the data returned by eth_sign when connected via WalletConnect) and encode it with 2 parts.

The first part contains the address of the owner and the type. This is encoded as 0x<left-padded-owner-address><left-padded-data-position><type-0>.

And the second part is the data.

If you have a Safe where the only owner would be an Argent wallet (e.g. 0xfBfe33a4462Ff0Bd86730499f65eBF7466914519) the signature bytes would look the following.

// Prefix
0x 
// Owner address: 0xfBfe33a4462Ff0Bd86730499f65eBF7466914519
000000000000000000000000fBfe33a4462Ff0Bd86730499f65eBF7466914519
// Data offset: 65 bytes (32 bytes for each r and s and 1 byte for v)
0000000000000000000000000000000000000000000000000000000000000041 
// Type
00
// Signature data returned by `eth_sign`
bde0b9f486b1960454e326375d0b1680243e031fd4fb3f070d9a3ef9871ccfd5
7d1a653cffb6321f889169f08e548684e005f2b0c3a6c06fba4c4a68f5e00624
1c

More details at: https://docs.gnosis-safe.io/contracts/signatures#contract-signature-eip-1271

2
  • Thanks Richard for the explanation, it makes more sense. However, I'm getting the following exception Fail with error 'Invalid contract signature location: data not complete' (GS023) for the following signature 0x0000000000000000000000002ac922cec780521f8ffab57d26b407936c352b820000000000000000000000000000000000000000000000000000000000000041003f65cc85fb5c5d059c1af0f716dec562bcab3d828bdb7dc91c059f4604413ce82999e73c6e971ff340f298cd1cd34272545c32c78b0a3e848dbebd48a0f96ed31c (txhash -> 0x49dfb17562ad7c0f0a55d46d4d1fec260fc9e95c29beadb5f4f75151a32ae1f3 Commented Mar 4, 2022 at 21:24
  • Ohh yeah mistake ob my side you need to include the length of the data
    – Richard
    Commented Mar 4, 2022 at 22:16

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.