Issue with Signature Verification in Safe Apps using Wagmi Core

Description

I’m currently integrating wallet connection and message signing in my application using multiple wallet connectors, including MetaMask, WalletConnect, Coinbase Wallet, Injected, Magic, and Safe. While the message signing and verification work perfectly with all connectors except Safe, I’m encountering an issue where the signature from Safe is not being verified correctly.

Code Snippet

We are using wagmi core for handling wallet connections and message signing. Here’s a simplified version of the relevant code:

javascript

Copy code

const handleConnection = async () => {

  try {
      let connector
      const connectorsMap = {
        metaMask: 0,
        walletConnect: 1,
        coinbaseWallet: 2,
        injected: 3,
        magic: 4,
        safe: 5,
      }
      connector = config.connectors[connectorsMap[setConnector.value] || 0]

      console.log('Connector Id:', setConnector.value)
      console.log('Connector:', connector)

      const instance = await connect(config, { connector })
      console.log('Instance:', instance)

      const timestamp = getAdjustedTimestamp()
      const message = `Levery Connection at ${timestamp}`
      console.log('Generated message:', message)

      // Get the account from the connection
      const connections = getConnections(config)
      const account = connections[0].accounts[0]

      console.log('Account:', account)

      // Signing the message using the account and connector
      const signature = await signMessage(config, {
        account,
        connector,
        message,
      })

      console.log('Signature:', signature)
      console.log('Connections:', connections)

      const valid = await verifyMessage({
        address: account,
        message,
        signature,
      })

      console.log('Valid:', valid)
      if (!valid) throw new Error('Verification failed.')

  } catch (e) {
    console.error('Error:', e);
    // Handle error
  }
};

Issue Encountered

The signing process in the Safe environment proceeds without errors, and I receive the signature as expected. However, when I attempt to verify the signature, it fails, and the validation returns false.

Any insights or suggestions would be greatly appreciated. Thank you in advance for your help!

1 Like

Hi there,

If you believe this is a bug in and you have steps to reproduce it, please file a bug in Safe Ecosystem Foundation · GitHub.

If you are looking for assistance with or have questions about building a SAFE integration, please ask on stack exchange instead Newest 'safe-core' Questions - Ethereum Stack Exchange