> For the complete documentation index, see [llms.txt](https://docs.ironblocks.com/firewall/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ironblocks.com/firewall/smart-contracts/firewalltransparentupgradableproxy.sol.md).

# FirewallTransparentUpgradableProxy.sol

`FirewallTransparentUpgradeableProxy` is Ironblocks' extended version of OpenZeppelin's [`TransparentUpgradableProxy`](https://docs.openzeppelin.com/contracts/3.x/api/proxy#TransparentUpgradeableProxy) contract.

Using this contract instead of the standard [`TransparentUpgradableProxy`](https://docs.openzeppelin.com/contracts/3.x/api/proxy#TransparentUpgradeableProxy) contract, alongside the [`FirewallProxyAdmin`](/firewall/smart-contracts/firewallproxyadmin.sol.md) instead of the standard [`ProxyAdmin`](https://docs.openzeppelin.com/contracts/3.x/api/proxy#ProxyAdmin) allows you to enable firewall protection on every one of your external methods without having to add any firewall-specific code to your implementation contract.

While the exact technical specifications of this implementation can be found in our [source code](#source-code), the important changes to note are the following:

1. The proxy constructor now receives the `firewall` address and `firewallAdmin` address.<br>
2. Similar to the implementation and admin addresses, these are stored in pseudorandom deterministic slots to prevent storage collision.<br>
3. The [Firewall Admin](/firewall/glossary.md#firewall-admin) is responsible for managing the [Firewall Consumer](/firewall/glossary.md#firewall-consumer) policies, and the standard admin can change the [Firewall](/firewall/glossary.md#firewall) and [Firewall Admin](/firewall/glossary.md#firewall-admin) addresses.

<br>

## Initialization

### constructor()

#### `constructor(address _logic, address admin_, bytes memory _data, address _firewall, address _firewallAdmin)`

Initializes a firewall upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and *optionally initialized with `_data` (as explained in* [*ERC1967Proxy-constructor*](https://eips.ethereum.org/EIPS/eip-1967)*).* Also sets `_firewall` and `_firewallAdmin`.

## Modifiers

### ifFirewallOrAdmin()

Used for routing calls to this [Firewall Proxy](/firewall/glossary.md#firewall-proxy) if they were called by the [Firewall](/firewall/glossary.md#firewall) or the [Firewall Admin](/firewall/glossary.md#firewall-admin). Otherwise, forwards calls to the implementation contract *(i.e. `_fallback()`).*

### firewallProtected()

Used to protect calls to the implementation contract, so that any calls to it would go through the [Firewall](/firewall/glossary.md#firewall)'s [Pre Execution](/firewall/glossary.md#pre-execution) and [Post Execution](/firewall/glossary.md#post-execution) hooks.

## Methods

### changeFirewall()

#### `function changeFirewall(address _firewall)`

Callable only by the [Firewall Admin](/firewall/glossary.md#firewall-admin), use this function to change the [Firewall](/firewall/glossary.md#firewall) that this [Firewall Proxy](/firewall/glossary.md#firewall-proxy) uses.

| Parameter Name | Type      | Description                                                              |
| -------------- | --------- | ------------------------------------------------------------------------ |
| `_firewall`    | `address` | the address of the new [Firewall](/firewall/glossary.md#firewall) to use |

### changeFirewallAdmin()

#### `function changeFirewallAdmin(address _firewallAdmin)`

Callable only by the [Firewall Admin](/firewall/glossary.md#firewall-admin),  use this function to change the [Firewall Admin](/firewall/glossary.md#firewall-admin) of the [Firewall](broken://pages/qu2xM6LA2zHewSfbCsWq#firewall) that this [Firewall Proxy](/firewall/glossary.md#firewall-proxy) uses.

| Parameter Name   | Type      | Description                                                                   |
| ---------------- | --------- | ----------------------------------------------------------------------------- |
| `_firewallAdmin` | `address` | the address of the new [Firewall Admin](/firewall/glossary.md#firewall-admin) |

### firewall()

#### `function firewall()`

Returns the current [Firewall](/firewall/glossary.md#firewall) address.

### firewallAdmin()

#### `function firewallAdmin()`

Returns the current [Firewall Admin](/firewall/glossary.md#firewall-admin) address.

## Source Code

On our GitLab repository: [FirewallTransparentUpgradeableProxy.sol](https://github.com/ironblocks/onchain-firewall/blob/main/packages/onchain-firewall/contracts/proxy/FirewallTransparentUpgradeableProxy.sol)
