Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Manage on-chain EVM and Solana wallets: balances, transfers, message signing, and transaction history via Privy Server Wallets.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
utils/DeploySafeCREATE2.sol
1// SPDX-License-Identifier: MIT2pragma solidity ^0.8.28;3import "forge-std/Script.sol";45interface ISafe {6function setup(7address[] calldata _owners,8uint256 _threshold,9address to,10bytes calldata data,11address fallbackHandler,12address paymentToken,13uint256 payment,14address payable paymentReceiver15) external;16}1718interface ISafeProxyFactory {19function createProxyWithNonce(20address _singleton,21bytes memory initializer,22uint256 saltNonce23) external returns (address);24}2526contract DeploySafeCREATE2 is Script {27address constant SAFE_SINGLETON = 0x29fcB43b46531BcA003ddC8FCB67FFE91900C762; // SafeL228address constant SAFE_PROXY_FACTORY = 0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67;29address constant FALLBACK_HANDLER = 0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99;3031uint256 constant MONAD_MAINNET_CHAIN_ID = 143;32uint256 constant MONAD_TESTNET_CHAIN_ID = 10143;3334function run() external returns (address) {35address owner1 = vm.envAddress("OWNER_1");36address owner2 = vm.envAddress("OWNER_2");37address owner3 = vm.envAddress("OWNER_3");3839address[] memory owners = new address[](3);40owners[0] = owner1;41owners[1] = owner2;42owners[2] = owner3;4344bytes memory initializer = abi.encodeWithSelector(45ISafe.setup.selector,46owners, // _owners472, // _threshold (2 of 3)48address(0), // to49"", // data50FALLBACK_HANDLER, // fallbackHandler51address(0), // paymentToken520, // payment53payable(0) // paymentReceiver54);5556vm.startBroadcast();5758// Deterministic if SALT_NONCE is fixed; default derives from owners + chainId59uint256 saltNonce = vm.envOr(60"SALT_NONCE",61uint256(keccak256(abi.encode(owners, block.chainid)))62);6364address proxy = ISafeProxyFactory(SAFE_PROXY_FACTORY).createProxyWithNonce(65SAFE_SINGLETON,66initializer,67saltNonce68);6970string memory safePrefix;71if (block.chainid == MONAD_MAINNET_CHAIN_ID) {72safePrefix = "monad";73} else if (block.chainid == MONAD_TESTNET_CHAIN_ID) {74safePrefix = "monad-testnet";75} else {76revert("Unsupported chain");77}7879console.log("Safe deployed at:", proxy);80console.log(81string.concat("Access: https://app.safe.global/home?safe=", safePrefix, ":"),82proxy83);8485vm.stopBroadcast();86return proxy;87}88}