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

add_new_safe_owners(web3, safe, deployer, ...)

Update Safe owners and threshold list.

calculate_deterministic_safe_address(web3, ...)

Pre-compute the deterministic Safe address without deploying.

deploy_safe(web3, deployer, owners, threshold)

Deploy a new Safe wallet.

deploy_safe_with_deterministic_address(web3, ...)

Deploy a new Safe wallet at a deterministic address using CREATE2.

disable_safe_module(web3, safe_address, ...)

Spoof Safe.disableModule() call on a forked mainnet.

fetch_safe_deployment(web3, address)

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_eth read 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_TIMEOUT for why this is longer than the generic transaction confirmation default.

  • web3 (Web3) –

  • safe (Safe) –

  • deployer (LocalAccount) –

  • owners (list[HexAddress | str]) –

  • 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

eth_typing.evm.HexAddress

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
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 owners list (same order)

  • Same threshold

  • Same salt_nonce

  • Same master_copy_address and proxy_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_eth read 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_TIMEOUT for 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
Return type

web3.contract.contract.ContractFunction

fetch_safe_deployment(web3, address)

Wrap Safe contract as Safe Python proxy object

Parameters
Return type

safe_eth.safe.safe.SafeV141