I am developing a Safe Module and would like to use Hardhat to test it. However, I have been so far unable to deploy a Safe using Hardhat. Does anyone have experience doing this? Even when I set my chainId to a chain I know SafeFactory exists for, I experience the error of Invalid Safeproxyfactory Address.
1 Answer
We run some Safe tests using Hardhat Network in our project. Here is the example: safe.spec.ts#L212
You have to deploy 3 contracts:
GnosisSafeProxyFactory.sol
GnosisSafe.sol
MultiSend.sol
Then you provide the addresses and the ABIs for Hardhat chainId
to gnosis SDK
import { SafeFactory } from '@gnosis.pm/safe-core-sdk'
// Initialize the Adapter and provide the deployed contract infos
const safeFactory = await SafeFactory.create({
ethAdapter,
contractNetworks: {
[client.chainId + '']: {
multiSendAddress: multiSendContract.address,
multiSendAbi: multiSendAbi,
safeMasterCopyAddress: safeContract.address,
safeMasterCopyAbi: safeAbi,
safeProxyFactoryAbi: proxyFactoryAbi,
safeProxyFactoryAddress: proxyFactoryContract.address
}
}
});