# SafeProxyFactory

The `SafeProxyFactory` contract is used to deploy `SafeProxy` contracts. The `SafeProxyFactory` contract provides various functions to deploy a `SafeProxy` contract which are given below.
The address of the proxy depends on the address of the `SafeProxyFactory` contract, `intializer` data, and the salt used to deploy the proxy.

## Functions available to deploy a `SafeProxy` contract

### `createProxyWithNonce`

```solidity
function createProxyWithNonce(address _singleton, bytes memory initializer, uint256 saltNonce) public returns (SafeProxy proxy);
```
Deploys a new proxy with the given singleton and nonce. Optionally executes a call to the new proxy. Emits `ProxyCreation` event on successful proxy creation.

### `createChainSpecificProxyWithNonce`

```solidity
function createChainSpecificProxyWithNonce(address _singleton, bytes memory initializer, uint256 saltNonce) public returns (SafeProxy proxy);
```
Deploys a chain-specific proxy with `_singleton` and `saltNonce`, ensuring it cannot be replayed on other networks. Emits `ProxyCreation` event on successful proxy creation.

### `createProxyWithCallback`

<Callout type='error' emoji='🚨'>
  The `createProxyWithCallback` method in the Safe proxy factory contract is deprecated. The callback execution is not guaranteed, and this method is no longer recommended for use. Developers should avoid relying on this functionality in production deployments.
</Callout>

```solidity
function createProxyWithCallback(address _singleton, bytes memory initializer, uint256 saltNonce, IProxyCreationCallback callback) public returns (SafeProxy proxy);
```
Deploys a new proxy, executes an optional call to the proxy, and invokes a specified callback. Emits `ProxyCreation` event on successful proxy creation.

## Events

### `ProxyCreation`
```solidity
event ProxyCreation(SafeProxy indexed proxy, address singleton);
```
Emitted when a new proxy contract is successfully created.

---

## Reference

- [SafeProxyFactory.sol](https://github.com/safe-global/safe-smart-account/blob/release/v1.4.1/contracts/proxies/SafeProxyFactory.sol)
- [IProxyCreationCallback](https://github.com/safe-global/safe-smart-account/blob/release/v1.4.1/contracts/proxies/IProxyCreationCallback.sol)
