1

We're working on deploying a contract that utilises Gnosis Safe and want to setup SafeGuard at the deployment time. We've come across this discussion (Deploying a contract that inherits GnosisSafe from another smart contract) that suggests we can achieve this.

What We Want to Achieve:

  • We need to pass parameters to set up our Safe, including to and data for the setGuard method of the created wallet.
  • To specify to parameter, we need to predict the address it will have.

We'd appreciate any insights or guidance on how to predict the address of the proxy for the Gnosis Safe contract in this context. Thank you!

Upd: I have found the method calculateCreateProxyWithNonceAddress in the GnosisSafeProxyFactory contract but it seems to be useless because the address we are looking for is the initializer param. Looks like It is impossible to predict the address in that context.

1 Answer 1

0

Not sure how to achieve that directly on the smart contract, but you could always do that on the client with JS and pass the predicted Safe address on your smart contract function call as an argument. Example code to predict the address on JS:

 const predictSafeAddress = useCallback(
    async ({ signer, ethAdapter }) => {
      if (web3AuthPack) {
        const safeFactory = await SafeFactory.create({
          ethAdapter,
          contractNetworks: ["0x5"],
        });

        const safeAccountConfig = {
          owners: [await signer.getAddress()],
          threshold: 1,
        };

        const predictedSafeAddress = await safeFactory.predictSafeAddress(
          safeAccountConfig
        );

        return { predictedSafeAddress, safeAccountConfig };
      }
    },
    [web3AuthPack]
  );

notes:

  • refactor contractNetworks to match the network you're deploying to, I currently have it hardcoded for Goerli
  • SafeFactory is imported from @safe-global/protocol-kit

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.