0

When signing a message with a SafeAppProvider (using Web3Provider from @ethersproject/providers) it used to just return 0x and we would call some methods on the safe contract to validate the signature. Now when I go to sign the message I get some errors in the console and consequently can't validate the signature. Instead of just returning 0x it now returns a full hash which I'm assuming is a mistake related to the errors in the console. What has changed? Why does signing the message not work anymore? Even if I decode the returned hash from signMessage, it won't validate because the signing address is not the same as the expected one

Code 613: Error fetching Safe message by message hash (404: An error occurred)
Status 404: https://safe-client.safe.global/v1/chains/1/messages/0x506c...

I would like to keep the current method of signing and validating to avoid having to install the protocol kit. But I tried using the lib anyway:

const protocolKit = await Safe.init({ provider, safeAddress })
const messageHash = await protocolKit.createMessage(message)
const sign = await protocolKit.signMessage(messageHash) // this is where it fails

Error: Messages can only be signed by Safe owners

The provider is the same as above. Somehow I can't figure out how to init the Safe without a private key. I just deployed a new safe on mainnet to test. Any suggestions how to sign using the current method or how to fix my implementation of the protocol kit?

Edit: I think the problem is that the address my provider has connected to is the safe contract where it should be connected to one of the owner accounts

Edit 2: I'd like to use protocol kit to have the safe sign the message using EIP-1271 (not EIP-712 as seems to be the default). How can I do that? From what I understand that's why we were using the magic value in the first place

1 Answer 1

0

Could you provide the error message(s) shown in your console? The Code 613 error you get arises because the message has not been signed, and therefore does not exist in the eyes of the client gateway.

When using the protocol kit, you should indeed (as per your edit 1) use a provider connected to one of the owners of the Safe.

For more information about how to sign messages (both using EIP-1271 and EIP-712-compatible typed messages), you can follow this guide from our docs.

Please let me know if it helped solve your problem? 🙏

Best, Louis

3
  • Thanks Louis! The guide won't work because I don't have access to any private keys. I'd like the safe to be the provider and the account signing the message (like I had it in the past, not the owner). Can you help me figure out why signer.signMessage doesn't work anymore when the provider is the safe? I think it somehow needs to be forced to use EIP1271 but I don't know how
    – Sophia
    Commented Jul 30 at 14:20
  • As for the error in the console, the Code 613 and Error 404 (shared above) are the only errors I receive. But strangely I'm seeing them when the Safe dialog pops up to sign the message - so before the actual signing happens
    – Sophia
    Commented Jul 30 at 14:23
  • You are right, you will need private keys from the owners to be able to sign messages on behalf of the safe. There is a section in the guide I sent you about exactly this (smart contract signatures), but I am not sure if it can be done without any private key. docs.safe.global/sdk/protocol-kit/guides/signatures/… Commented Jul 31 at 13:43

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.