Last active
June 10, 2025 11:30
-
-
Save rmeissner/114c4e601dfc6142976b55c35203db2f to your computer and use it in GitHub Desktop.
SafeDeployer.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: Unlicense | |
pragma solidity >=0.7.0 <0.9.0; | |
// src/SafeDeployer141.sol | |
contract SafeDeployer141 { | |
// These addresses must be predeployed on worldchain to ensure that wallet address calc is deterministic | |
address public SAFE_PROXY_FACTORY_ADDRESS = 0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67; | |
address public SAFE_L2_SINGLETON_ADDRESS = 0x29fcB43b46531BcA003ddC8FCB67FFE91900C762; | |
address public SAFE_4337_MODULE_ADDRESS = 0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226; | |
address public SAFE_MODULE_SETUP_ADDRESS = 0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47; | |
constructor() {} | |
event WalletDeployment141(address wallet, bool success); | |
function deploy(address eoaOwner) public view returns (address proxyFactory, address singletonAddress, bytes memory initializer, uint256 saltNonce, bytes memory initCallData){ | |
// https://github.com/safe-global/safe-modules/tree/main/modules/4337#setup-flow | |
// Setup modules array | |
address[] memory modules = new address[](1); | |
{ | |
modules[0] = SAFE_4337_MODULE_ADDRESS; | |
} | |
/** | |
* Setup Owners array * | |
*/ | |
address[] memory owners = new address[](1); | |
{ | |
owners[0] = eoaOwner; | |
} | |
initializer = abi.encodeWithSignature( | |
"setup(address[],uint256,address,bytes,address,address,uint256,address)", | |
owners, | |
1, // Threshold | |
SAFE_MODULE_SETUP_ADDRESS, | |
abi.encodeWithSignature("enableModules(address[])", modules), | |
SAFE_4337_MODULE_ADDRESS, | |
// We do not want to use any refund logic; therefore, this is all set to 0 | |
address(0), | |
0, | |
address(0) | |
); | |
initCallData = abi.encodeWithSignature( | |
"createProxyWithNonce(address,bytes,uint256)", | |
SAFE_L2_SINGLETON_ADDRESS, | |
initializer, | |
// We use nonce = 0 for all new wallets, we used to use signupCounter | |
0 | |
); | |
return (SAFE_PROXY_FACTORY_ADDRESS, SAFE_L2_SINGLETON_ADDRESS, initializer, 0, initCallData); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment