safe.deployment
Documentation for eth_defi.safe.deployment Python module.
Deploy Safe multisig wallets.
Helpers for deploying Safe, managing owners and modifying the deployment
Safe source code:
Functions
|
Update Safe owners and threshold list. |
|
Pre-compute the deterministic Safe address without deploying. |
|
Deploy a new Safe wallet. |
|
Deploy a new Safe wallet at a deterministic address using CREATE2. |
|
Spoof Safe.disableModule() call on a forked mainnet. |
|
Wrap Safe contract as Safe Python proxy object |
- add_new_safe_owners(web3, safe, deployer, owners, threshold, gas_per_tx=500000, gnosis_safe_state_safety_sleep=12, hot_wallet=None, tx_confirmation_timeout=300.0)
Update Safe owners and threshold list.
Safe cannot replace the existing owner list
Designed to create the owner list after a deployment.
The multisig must be in 1-of-1 deployer state
Note
We cannot remove deployer account from the list, but it must be done by the new owners
- Parameters
gas_per_tx – Gas limit for a single transaction.
between_calls_sleep – Deployer hack
hot_wallet (HotWallet | None) – When provided, allocate transaction nonces from the wallet’s internal counter instead of letting
safe_ethread from the RPC node. Avoids stale-nonce errors on load-balanced endpoints.tx_confirmation_timeout (float) –
How long to wait for each transaction to be mined, in seconds.
See
DEFAULT_TX_CONFIRMATION_TIMEOUTfor why this is longer than the generic transaction confirmation default.web3 (Web3) –
safe (Safe) –
deployer (LocalAccount) –
threshold (int) –
More info:
- calculate_deterministic_safe_address(web3, owners, threshold, salt_nonce, master_copy_address='0x29fcB43b46531BcA003ddC8FCB67FFE91900C762', proxy_factory_address='0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67')
Pre-compute the deterministic Safe address without deploying.
Uses the same CREATE2 formula as
deploy_safe_with_deterministic_address()to predict the Safe proxy address before deployment. The address depends only on the owner list, threshold, salt nonce, master copy, and proxy factory — all of which are the same on every EVM chain, enabling cross-chain address prediction.- Parameters
owners (list[eth_typing.evm.HexAddress | str]) – List of owner addresses. Must be in the same order across chains.
threshold (int) – Number of required confirmations.
salt_nonce (int) – Uint256 salt for CREATE2. Use the same value across chains for the same address.
master_copy_address (Union[eth_typing.evm.HexAddress, str]) – Safe singleton address. Default is Safe v1.4.1 L2.
proxy_factory_address (Union[eth_typing.evm.HexAddress, str]) – Safe ProxyFactory address. Default is the canonical v1.4.1 factory.
web3 (web3.main.Web3) –
- Returns
The predicted Safe proxy address.
- Return type
- deploy_safe(web3, deployer, owners, threshold, master_copy_address='0x29fcB43b46531BcA003ddC8FCB67FFE91900C762', post_deploy_delay_seconds=10.0, tx_confirmation_timeout=300.0)
Deploy a new Safe wallet.
Use version Safe v 1.4.1
- Parameters
deployer (eth_account.signers.local.LocalAccount) – Must be LocalAccount due to Safe library limitations.
tx_confirmation_timeout (float) –
How long to wait for the deployment transaction to be mined, in seconds.
See
DEFAULT_TX_CONFIRMATION_TIMEOUTfor why this is longer than the generic transaction confirmation default.master_copy_address –
Default Safe 1.4.1 layer two master copy address.
See
MASTER_COPIESUse +L2 version tag for Layer two chains
Discussion
web3 (web3.main.Web3) –
owners (list[eth_typing.evm.HexAddress | str]) –
threshold (int) –
- Return type
safe_eth.safe.safe.Safe
- deploy_safe_with_deterministic_address(web3, deployer, owners, threshold, salt_nonce, master_copy_address='0x29fcB43b46531BcA003ddC8FCB67FFE91900C762', proxy_factory_address='0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67', post_deploy_delay_seconds=10.0, hot_wallet=None, tx_confirmation_timeout=300.0)
Deploy a new Safe wallet at a deterministic address using CREATE2.
Uses the canonical Safe v1.4.1 ProxyFactory (deployed at the same address on all EVM chains) with
createProxyWithNonce()to produce the same Safe address across multiple chains, given identical parameters.For cross-chain deterministic deployment, ensure:
Same
ownerslist (same order)Same
thresholdSame
salt_nonceSame
master_copy_addressandproxy_factory_address(defaults are fine)
- Parameters
deployer (LocalAccount) – Must be LocalAccount due to Safe library limitations.
owners (list[HexAddress | str]) – List of owner addresses. Must be in the same order across chains.
threshold (int) – Number of required confirmations.
salt_nonce (int) – Uint256 salt for CREATE2. Use the same value across chains for the same address.
master_copy_address (HexAddress | str) – Safe singleton address. Default is Safe v1.4.1 L2.
proxy_factory_address (HexAddress | str) – Safe ProxyFactory address. Default is the canonical v1.4.1 factory.
post_deploy_delay_seconds (float) – Sleep after deployment on non-Anvil networks to let state propagate.
hot_wallet (HotWallet | None) – When provided, allocate the transaction nonce from the wallet’s internal counter instead of letting
safe_ethread from the RPC node. Avoids stale-nonce errors on load-balanced endpoints.tx_confirmation_timeout (float) –
How long to wait for the deployment transaction to be mined, in seconds.
See
DEFAULT_TX_CONFIRMATION_TIMEOUTfor why this is longer than the generic transaction confirmation default.web3 (Web3) –
- Return type
Safe
- disable_safe_module(web3, safe_address, module_address)
Spoof Safe.disableModule() call on a forked mainnet.
Safe makes disable module transaction unnecessary complicated, because the internal linked list is exposed
- Raises
ValueError – Module is not enabled.
- Returns
Bound ContractFunction to call on the Safe contract.
- Parameters
web3 (web3.main.Web3) –
safe_address (str) –
module_address (Union[eth_typing.evm.HexAddress, str]) –
- Return type
web3.contract.contract.ContractFunction
- fetch_safe_deployment(web3, address)
Wrap Safe contract as Safe Python proxy object
- Parameters
web3 (web3.main.Web3) –
address (Union[eth_typing.evm.HexAddress, str]) –
- Return type
safe_eth.safe.safe.SafeV141