2

A dApp that i'm working on supports connecting with WalletConnect. Considering that Gnosis Safe apps require additional custom logic to get even the basic functionality like waiting for transactions and signatures working - is there a reliable way to detect whether a given address is a Gnosis Safe wallet?

1

2 Answers 2

3

To know if an address is a Safe there are a few steps you can follow:

  1. Check that the account is a contract.
  2. Safe uses the proxy pattern. Make sure that the bytecode of the contract (the proxy contract) matches the Safe proxy contract bytecode.
  3. Check that the proxy contract is pointing to one of the Safe singleton contracts. Depending on the version of the Safe and the network, the singleton will be one of these. Find the gnosis_safe.json or gnosis_safe_l2.json files inside each folder and see the list of addresses where the singletons are deployed for each network.

There is no really a good way to make sure that an address is a Safe, but this should be a good approach.

0

Identifying the type of connected wallet in a dApp can pose a challenge due to the absence of any standardized metadata that indicates the wallet's type (as discussed here). However, there are a couple of approaches that can potentially aid in distinguishing between different wallets:

User Selection: Before initiating the connection process, prompt users to manually select their wallet type. Although this approach is straightforward and scalable, its accuracy relies on user honesty.

Programmatic Detection: Specifically for Gnosis Safe, while it's possible to programmatically detect if a wallet is a Gnosis Safe wallet by examining certain contract-based characteristics (as described by Germán), there's another method that can be used when working within the Safe Apps environment. You can use the useSafeAppsSDK hook to check if a Safe wallet is connected:

import { useSafeAppsSDK } from '@safe-global/safe-apps-react-sdk';
const { connected: isSafeWalletConnected } = useSafeAppsSDK();
// isSafeWalletConnected is true if connected in a safe context

Remember that this only works in a Safe context, i.e., when your app is running as a Safe App within the Gnosis Safe interface. In such cases, your domain should match the allowedDomains ([/gnosis-safe.io$/, /app.safe.global$/]).

Please note that these methods have their limitations and might not always accurately detect the wallet type.

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.