safe-core-sdk: Getting "Error: Safe Proxy contract is not deployed in the current network" after calling safeFactory.deploySafe()
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.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 16 (2 by maintainers)
Hi @germartinez,
Can we open up this ticket? I am facing this exact issue on Polygon using an EthersAdapter, every time
safeFactory.deplySafe()is called I am gettingError: Safe Proxy contract is not deployed in the current network.I am having no problem when on Mumbai but this happens consistently on Polygon.
Environment
Steps to reproduce
The bug can be reproduced by running the above code with the Metamask extension installed in the browser and set on Polygon mainnet.
Also getting
Error: SafeProxy contract is not deployed on the current networkoccasionally (maybe 1 out of 10 times) with the Web3Adapter on Goerli and Infura as an RPC provider. Could it be a sync issue? Any idea how to solve this?This is how I’m using it:
Hi @c-jain and @dntxos, This should have been fixed with the merge of the linked PR into the
developmentbranch. Thank you for reporting this issue, web3 tests are working again now.ok, so to use ether.js instead of web3.js? I will try and check, thanks. Hope, gnosis team look for web3.js as well as it should work with web3.js as well.
I was able to overcome this issue by using EtherAdapter instead of Web3Adapter
Hi Gnosis team, kindly consider looking into this issue which is not resolved yet. @katspaugh @rudolfs @vorot93 @koeppelmann