safe-core-sdk icon indicating copy to clipboard operation
safe-core-sdk copied to clipboard

Getting "Error: Safe Proxy contract is not deployed in the current network" after calling safeFactory.deploySafe()

Open c-jain opened this issue 2 years ago • 16 comments

Description

I am able to deploy a safe proxy contract on the Rinkeby testnet but I am facing an issue. After calling safeFactory.deploySafe(), the function waits for some time then give both error and Metamask notification at the same time. I wanted to understand, is it normal to get this error and then manually get the deployed safe proxy contract address from the Etherscan or not?

My use case is whenever a user creates a safe then I should be able to store their deployed safe proxy contract address on my backend automatically and not manually by asking the user to go and check Etherscan and then save it on the backend via some frontend UI.

Environment

  • Safe Core SDK version: 1.1.1
  • Safe contract version: 1.3.0
  • @ethersproject/solidity version: 5.5.0
  • ethers version: 5.5.2
  • web3 version: 1.6.1
  • Environment:
    • browser: A Next.js app

Steps to reproduce

import Safe, { Web3Adapter, SafeFactory } from '@gnosis.pm/safe-core-sdk'

const deploySafe = async () => {
  try {
    const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' })
    const web3 = new Web3(window.ethereum)
    const web3Adapter = new Web3Adapter({ web3, signerAddress: accounts[0] })
    const safeFactory = await SafeFactory.create({ ethAdapter: web3Adapter })
    const owners = [accounts[0]]
    const threshold = 1
    const safeAccountConfig = { owners, threshold }
    const safeSdk = await safeFactory.deploySafe(safeAccountConfig)
    return Promise.resolve(safeSdk)
  } catch (err) {
    console.log('[deploySafe]:', err) // Here I get error.
    return Promise.reject(err)
  }
}

The bug can be reproduced by running the above code with the Metamask extension installed in the browser and set on Rinkeby testnet.

Expected result

In some different file:

const safeSdk = await deploySafe()
const newSafeAddress = safeSdk.getAddress()
// Call my API to store the newSafeAddress on the backend, so that it can later be used with Safe Service Client SDK.

Additional context

I also asked the issue on the StackExchange.

c-jain avatar Dec 21 '21 07:12 c-jain