---
title: "Proxy"
description: "Smart contract proxy utilities and implementations"
---

This is a low-level set of contracts implementing different proxy patterns with and without upgradeability. For an in-depth overview of this pattern check out the [Proxy Upgrade Pattern](/upgrades-plugins/proxies) page.

Most of the proxies below are built on an abstract base contract.

* [`Proxy`](#Proxy): Abstract contract implementing the core delegation functionality.

In order to avoid clashes with the storage variables of the implementation contract behind a proxy, we use [ERC-1967](https://eips.ethereum.org/EIPS/eip-1967) storage slots.

* [`ERC1967Utils`](#ERC1967Utils): Internal functions to get and set the storage slots defined in ERC-1967.
* [`ERC1967Proxy`](#ERC1967Proxy): A proxy using ERC-1967 storage slots. Not upgradeable by default.

There are two alternative ways to add upgradeability to an ERC-1967 proxy. Their differences are explained below in [Transparent vs UUPS Proxies](#transparent-vs-uups-proxies).

* [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy): A proxy with a built-in immutable admin and upgrade interface.
* [`UUPSUpgradeable`](#UUPSUpgradeable): An upgradeability mechanism to be included in the implementation contract.

**🔥 CAUTION**\
Using upgradeable proxies correctly and securely is a difficult task that requires deep knowledge of the proxy pattern, Solidity, and the EVM. Unless you want a lot of low level control, we recommend using the [OpenZeppelin Upgrades Plugins](/upgrades-plugins) for Hardhat and Foundry.

A different family of proxies is beacon proxies. This pattern, popularized by Dharma, allows multiple proxies to be upgraded to a different implementation in a single transaction.

* [`BeaconProxy`](#BeaconProxy): A proxy that retrieves its implementation from a beacon contract.
* [`UpgradeableBeacon`](#UpgradeableBeacon): A beacon contract with a built-in admin that can upgrade the [`BeaconProxy`](#BeaconProxy) pointing to it.

In this pattern, the proxy contract doesn’t hold the implementation address in storage like an ERC-1967 proxy. Instead, the address is stored in a separate beacon contract. The `upgrade` operations are sent to the beacon instead of to the proxy contract, and all proxies that follow that beacon are automatically upgraded.

Outside the realm of upgradeability, proxies can also be useful to make cheap contract clones, such as those created by an on-chain factory contract that creates many instances of the same contract. These instances are designed to be both cheap to deploy, and cheap to call.

* [`Clones`](#Clones): A library that can deploy cheap minimal non-upgradeable proxies.

## Transparent vs UUPS Proxies

The original proxies included in OpenZeppelin followed the [Transparent Proxy Pattern](https://blog.openzeppelin.com/the-transparent-proxy-pattern/). While this pattern is still provided, our recommendation is now shifting towards UUPS proxies, which are both lightweight and versatile. The name UUPS comes from [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822), which first documented the pattern.

While both of these share the same interface for upgrades, in UUPS proxies the upgrade is handled by the implementation, and can eventually be removed. Transparent proxies, on the other hand, include the upgrade and admin logic in the proxy itself. This means [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy) is more expensive to deploy than what is possible with UUPS proxies.

UUPS proxies are implemented using an [`ERC1967Proxy`](#ERC1967Proxy). Note that this proxy is not by itself upgradeable. It is the role of the implementation to include, alongside the contract’s logic, all the code necessary to update the implementation’s address that is stored at a specific slot in the proxy’s storage space. This is where the [`UUPSUpgradeable`](#UUPSUpgradeable) contract comes in. Inheriting from it (and overriding the [`_authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-) function with the relevant access control mechanism) will turn your contract into a UUPS compliant implementation.

Note that since both proxies use the same storage slot for the implementation address, using a UUPS compliant implementation with a [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy) might allow non-admins to perform upgrade operations.

By default, the upgrade functionality included in [`UUPSUpgradeable`](#UUPSUpgradeable) contains a security mechanism that will prevent any upgrades to a non UUPS compliant implementation. This prevents upgrades to an implementation contract that wouldn’t contain the necessary upgrade mechanism, as it would lock the upgradeability of the proxy forever. This security mechanism can be bypassed by either of:

* Adding a flag mechanism in the implementation that will disable the upgrade function when triggered.
* Upgrading to an implementation that features an upgrade mechanism without the additional security check, and then upgrading again to another implementation without the upgrade mechanism.

The current implementation of this security mechanism uses [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822) to detect the storage slot used by the implementation. A previous implementation, now deprecated, relied on a rollback check. It is possible to upgrade from a contract using the old mechanism to a new one. The inverse is however not possible, as old implementations (before version 4.5) did not include the ERC-1822 interface.

## Core

[`Proxy`](#Proxy)

## ERC-1967

[`IERC1967`](/contracts/5.x/api/interfaces#IERC1967)

[`ERC1967Proxy`](#ERC1967Proxy)

[`ERC1967Utils`](#ERC1967Utils)

## Transparent Proxy

[`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy)

[`ProxyAdmin`](#ProxyAdmin)

## Beacon

[`BeaconProxy`](#BeaconProxy)

[`IBeacon`](#IBeacon)

[`UpgradeableBeacon`](#UpgradeableBeacon)

## Minimal Clones

[`Clones`](#Clones)

## Utils

[`Initializable`](#Initializable)

[`UUPSUpgradeable`](#UUPSUpgradeable)

<a id="Clones"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `Clones` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/Clones.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/Clones.sol";
```

[ERC-1167](https://eips.ethereum.org/EIPS/eip-1167) is a standard for
deploying minimal proxy contracts, also known as "clones".

> To simply and cheaply clone contract functionality in an immutable way, this standard specifies
> a minimal bytecode implementation that delegates all calls to a known, fixed address.

The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
(salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
deterministic method.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [clone(implementation)](#Clones-clone-address-)
- [clone(implementation, value)](#Clones-clone-address-uint256-)
- [cloneDeterministic(implementation, salt)](#Clones-cloneDeterministic-address-bytes32-)
- [cloneDeterministic(implementation, salt, value)](#Clones-cloneDeterministic-address-bytes32-uint256-)
- [predictDeterministicAddress(implementation, salt, deployer)](#Clones-predictDeterministicAddress-address-bytes32-address-)
- [predictDeterministicAddress(implementation, salt)](#Clones-predictDeterministicAddress-address-bytes32-)
- [cloneWithImmutableArgs(implementation, args)](#Clones-cloneWithImmutableArgs-address-bytes-)
- [cloneWithImmutableArgs(implementation, args, value)](#Clones-cloneWithImmutableArgs-address-bytes-uint256-)
- [cloneDeterministicWithImmutableArgs(implementation, args, salt)](#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-)
- [cloneDeterministicWithImmutableArgs(implementation, args, salt, value)](#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-uint256-)
- [predictDeterministicAddressWithImmutableArgs(implementation, args, salt, deployer)](#Clones-predictDeterministicAddressWithImmutableArgs-address-bytes-bytes32-address-)
- [predictDeterministicAddressWithImmutableArgs(implementation, args, salt)](#Clones-predictDeterministicAddressWithImmutableArgs-address-bytes-bytes32-)
- [fetchCloneArgs(instance)](#Clones-fetchCloneArgs-address-)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [CloneArgumentsTooLong()](#Clones-CloneArgumentsTooLong--)
</div>
</div>

<a id="Clones-clone-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">clone(address implementation) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-clone-address-">#</a>
</div>
</div>
<div className="px-4">

Deploys and returns the address of a clone that mimics the behavior of `implementation`.

This function uses the create opcode, which should never revert.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

</div>
</div>

<a id="Clones-clone-address-uint256-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">clone(address implementation, uint256 value) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-clone-address-uint256-">#</a>
</div>
</div>
<div className="px-4">

Same as [clone](#Clones-clone-address-), but with a `value` parameter to send native currency
to the new contract.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

<Callout>
Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
</Callout>

</div>
</div>

<a id="Clones-cloneDeterministic-address-bytes32-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">cloneDeterministic(address implementation, bytes32 salt) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-cloneDeterministic-address-bytes32-">#</a>
</div>
</div>
<div className="px-4">

Deploys and returns the address of a clone that mimics the behavior of `implementation`.

This function uses the create2 opcode and a `salt` to deterministically deploy
the clone. Using the same `implementation` and `salt` multiple times will revert, since
the clones cannot be deployed twice at the same address.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

</div>
</div>

<a id="Clones-cloneDeterministic-address-bytes32-uint256-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">cloneDeterministic(address implementation, bytes32 salt, uint256 value) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-cloneDeterministic-address-bytes32-uint256-">#</a>
</div>
</div>
<div className="px-4">

Same as [cloneDeterministic](#Clones-cloneDeterministic-address-bytes32-), but with
a `value` parameter to send native currency to the new contract.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

<Callout>
Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
</Callout>

</div>
</div>

<a id="Clones-predictDeterministicAddress-address-bytes32-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">predictDeterministicAddress(address implementation, bytes32 salt, address deployer) → address predicted</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-predictDeterministicAddress-address-bytes32-address-">#</a>
</div>
</div>
<div className="px-4">

Computes the address of a clone deployed using [`Clones.cloneDeterministic`](#Clones-cloneDeterministic-address-bytes32-uint256-).

</div>
</div>

<a id="Clones-predictDeterministicAddress-address-bytes32-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">predictDeterministicAddress(address implementation, bytes32 salt) → address predicted</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-predictDeterministicAddress-address-bytes32-">#</a>
</div>
</div>
<div className="px-4">

Computes the address of a clone deployed using [`Clones.cloneDeterministic`](#Clones-cloneDeterministic-address-bytes32-uint256-).

</div>
</div>

<a id="Clones-cloneWithImmutableArgs-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">cloneWithImmutableArgs(address implementation, bytes args) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-cloneWithImmutableArgs-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Deploys and returns the address of a clone that mimics the behavior of `implementation` with custom
immutable arguments. These are provided through `args` and cannot be changed after deployment. To
access the arguments within the implementation, use [`Clones.fetchCloneArgs`](#Clones-fetchCloneArgs-address-).

This function uses the create opcode, which should never revert.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

</div>
</div>

<a id="Clones-cloneWithImmutableArgs-address-bytes-uint256-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">cloneWithImmutableArgs(address implementation, bytes args, uint256 value) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-cloneWithImmutableArgs-address-bytes-uint256-">#</a>
</div>
</div>
<div className="px-4">

Same as [cloneWithImmutableArgs](#Clones-cloneWithImmutableArgs-address-bytes-), but with a `value`
parameter to send native currency to the new contract.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

<Callout>
Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
</Callout>

</div>
</div>

<a id="Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">cloneDeterministicWithImmutableArgs(address implementation, bytes args, bytes32 salt) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-">#</a>
</div>
</div>
<div className="px-4">

Deploys and returns the address of a clone that mimics the behavior of `implementation` with custom
immutable arguments. These are provided through `args` and cannot be changed after deployment. To
access the arguments within the implementation, use [`Clones.fetchCloneArgs`](#Clones-fetchCloneArgs-address-).

This function uses the create2 opcode and a `salt` to deterministically deploy the clone. Using the same
`implementation`, `args` and `salt` multiple times will revert, since the clones cannot be deployed twice
at the same address.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

</div>
</div>

<a id="Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-uint256-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">cloneDeterministicWithImmutableArgs(address implementation, bytes args, bytes32 salt, uint256 value) → address instance</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-uint256-">#</a>
</div>
</div>
<div className="px-4">

Same as [cloneDeterministicWithImmutableArgs](#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-),
but with a `value` parameter to send native currency to the new contract.

<Callout type="warn">
This function does not check if `implementation` has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
</Callout>

<Callout>
Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
</Callout>

</div>
</div>

<a id="Clones-predictDeterministicAddressWithImmutableArgs-address-bytes-bytes32-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">predictDeterministicAddressWithImmutableArgs(address implementation, bytes args, bytes32 salt, address deployer) → address predicted</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-predictDeterministicAddressWithImmutableArgs-address-bytes-bytes32-address-">#</a>
</div>
</div>
<div className="px-4">

Computes the address of a clone deployed using [`Clones.cloneDeterministicWithImmutableArgs`](#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-uint256-).

</div>
</div>

<a id="Clones-predictDeterministicAddressWithImmutableArgs-address-bytes-bytes32-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">predictDeterministicAddressWithImmutableArgs(address implementation, bytes args, bytes32 salt) → address predicted</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-predictDeterministicAddressWithImmutableArgs-address-bytes-bytes32-">#</a>
</div>
</div>
<div className="px-4">

Computes the address of a clone deployed using [`Clones.cloneDeterministicWithImmutableArgs`](#Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-uint256-).

</div>
</div>

<a id="Clones-fetchCloneArgs-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">fetchCloneArgs(address instance) → bytes</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Clones-fetchCloneArgs-address-">#</a>
</div>
</div>
<div className="px-4">

Get the immutable args attached to a clone.

- If `instance` is a clone that was deployed using `clone` or `cloneDeterministic`, this
  function will return an empty array.
- If `instance` is a clone that was deployed using `cloneWithImmutableArgs` or
  `cloneDeterministicWithImmutableArgs`, this function will return the args array used at
  creation.
- If `instance` is NOT a clone deployed using this library, the behavior is undefined. This
  function should only be used to check addresses that are known to be clones.

</div>
</div>

<a id="Clones-CloneArgumentsTooLong--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">CloneArgumentsTooLong()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#Clones-CloneArgumentsTooLong--">#</a>
</div>
</div>
<div className="px-4">

</div>
</div>

<a id="ERC1967Proxy"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `ERC1967Proxy` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/ERC1967/ERC1967Proxy.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
```

This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
implementation address that can be changed. This address is stored in storage in the location specified by
[ERC-1967](https://eips.ethereum.org/EIPS/eip-1967), so that it doesn't conflict with the storage layout of the
implementation behind the proxy.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [constructor(implementation, _data)](#ERC1967Proxy-constructor-address-bytes-)
- [_implementation()](#ERC1967Proxy-_implementation--)
- [_unsafeAllowUninitialized()](#ERC1967Proxy-_unsafeAllowUninitialized--)
<details>
<summary>Proxy</summary>

- [_delegate(implementation)](#Proxy-_delegate-address-)
- [_fallback()](#Proxy-_fallback--)
- [fallback()](#Proxy-fallback--)

</details>
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [ERC1967ProxyUninitialized()](#ERC1967Proxy-ERC1967ProxyUninitialized--)
</div>
</div>

<a id="ERC1967Proxy-constructor-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">constructor(address implementation, bytes _data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#ERC1967Proxy-constructor-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Initializes the upgradeable proxy with an initial implementation specified by `implementation`.

Provided `_data` is passed in a delegate call to `implementation`. This will typically be an encoded function
call, and allows initializing the storage of the proxy like a Solidity constructor. By default construction
will fail if `_data` is empty. This behavior can be overridden using a custom [`ERC1967Proxy._unsafeAllowUninitialized`](#ERC1967Proxy-_unsafeAllowUninitialized--) that
returns true. In that case, empty `_data` is ignored and no delegate call to the implementation is performed
during construction.

Requirements:

- If `data` is empty, `msg.value` must be zero.

</div>
</div>

<a id="ERC1967Proxy-_implementation--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_implementation() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Proxy-_implementation--">#</a>
</div>
</div>
<div className="px-4">

Returns the current implementation address.

<Callout>
To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
the [`eth_getStorageAt`](https://eth.wiki/json-rpc/API#eth_getstorageat) RPC call.
`0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
</Callout>

</div>
</div>

<a id="ERC1967Proxy-_unsafeAllowUninitialized--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_unsafeAllowUninitialized() → bool</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Proxy-_unsafeAllowUninitialized--">#</a>
</div>
</div>
<div className="px-4">

Returns whether the proxy can be left uninitialized.

<Callout>
Override this function to allow the proxy to be left uninitialized.
Consider uninitialized proxies might be susceptible to man-in-the-middle threats
where the proxy is replaced with a malicious one.
</Callout>

</div>
</div>

<a id="ERC1967Proxy-ERC1967ProxyUninitialized--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">ERC1967ProxyUninitialized()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#ERC1967Proxy-ERC1967ProxyUninitialized--">#</a>
</div>
</div>
<div className="px-4">

The proxy is left uninitialized.

</div>
</div>

<a id="ERC1967Utils"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `ERC1967Utils` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/ERC1967/ERC1967Utils.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
```

This library provides getters and event emitting update functions for
[ERC-1967](https://eips.ethereum.org/EIPS/eip-1967) slots.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [getImplementation()](#ERC1967Utils-getImplementation--)
- [upgradeToAndCall(newImplementation, data)](#ERC1967Utils-upgradeToAndCall-address-bytes-)
- [getAdmin()](#ERC1967Utils-getAdmin--)
- [changeAdmin(newAdmin)](#ERC1967Utils-changeAdmin-address-)
- [getBeacon()](#ERC1967Utils-getBeacon--)
- [upgradeBeaconToAndCall(newBeacon, data)](#ERC1967Utils-upgradeBeaconToAndCall-address-bytes-)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [ERC1967InvalidImplementation(implementation)](#ERC1967Utils-ERC1967InvalidImplementation-address-)
- [ERC1967InvalidAdmin(admin)](#ERC1967Utils-ERC1967InvalidAdmin-address-)
- [ERC1967InvalidBeacon(beacon)](#ERC1967Utils-ERC1967InvalidBeacon-address-)
- [ERC1967NonPayable()](#ERC1967Utils-ERC1967NonPayable--)
</div>
</div>

<a id="ERC1967Utils-getImplementation--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">getImplementation() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Utils-getImplementation--">#</a>
</div>
</div>
<div className="px-4">

Returns the current implementation address.

</div>
</div>

<a id="ERC1967Utils-upgradeToAndCall-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">upgradeToAndCall(address newImplementation, bytes data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Utils-upgradeToAndCall-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Performs implementation upgrade with additional setup call if data is nonempty.
This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
to avoid stuck value in the contract.

Emits an [`IERC1967.Upgraded`](/contracts/5.x/api/interfaces#IERC1967-Upgraded-address-) event.

</div>
</div>

<a id="ERC1967Utils-getAdmin--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">getAdmin() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Utils-getAdmin--">#</a>
</div>
</div>
<div className="px-4">

Returns the current admin.

<Callout>
To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
the [`eth_getStorageAt`](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getstorageat) RPC call.
`0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
</Callout>

</div>
</div>

<a id="ERC1967Utils-changeAdmin-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">changeAdmin(address newAdmin)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Utils-changeAdmin-address-">#</a>
</div>
</div>
<div className="px-4">

Changes the admin of the proxy.

Emits an [`IERC1967.AdminChanged`](/contracts/5.x/api/interfaces#IERC1967-AdminChanged-address-address-) event.

</div>
</div>

<a id="ERC1967Utils-getBeacon--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">getBeacon() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Utils-getBeacon--">#</a>
</div>
</div>
<div className="px-4">

Returns the current beacon.

</div>
</div>

<a id="ERC1967Utils-upgradeBeaconToAndCall-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">upgradeBeaconToAndCall(address newBeacon, bytes data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#ERC1967Utils-upgradeBeaconToAndCall-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Change the beacon and trigger a setup call if data is nonempty.
This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
to avoid stuck value in the contract.

Emits an [`IERC1967.BeaconUpgraded`](/contracts/5.x/api/interfaces#IERC1967-BeaconUpgraded-address-) event.

<Callout type="warn">
Invoking this function has no effect on an instance of [`BeaconProxy`](#BeaconProxy) since v5, since
it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
efficiency.
</Callout>

</div>
</div>

<a id="ERC1967Utils-ERC1967InvalidImplementation-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">ERC1967InvalidImplementation(address implementation)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#ERC1967Utils-ERC1967InvalidImplementation-address-">#</a>
</div>
</div>
<div className="px-4">

The `implementation` of the proxy is invalid.

</div>
</div>

<a id="ERC1967Utils-ERC1967InvalidAdmin-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">ERC1967InvalidAdmin(address admin)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#ERC1967Utils-ERC1967InvalidAdmin-address-">#</a>
</div>
</div>
<div className="px-4">

The `admin` of the proxy is invalid.

</div>
</div>

<a id="ERC1967Utils-ERC1967InvalidBeacon-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">ERC1967InvalidBeacon(address beacon)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#ERC1967Utils-ERC1967InvalidBeacon-address-">#</a>
</div>
</div>
<div className="px-4">

The `beacon` of the proxy is invalid.

</div>
</div>

<a id="ERC1967Utils-ERC1967NonPayable--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">ERC1967NonPayable()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#ERC1967Utils-ERC1967NonPayable--">#</a>
</div>
</div>
<div className="px-4">

An upgrade function sees `msg.value > 0` that may be lost.

</div>
</div>

<a id="Proxy"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `Proxy` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/Proxy.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/Proxy.sol";
```

This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
be specified by overriding the virtual [`ERC1967Proxy._implementation`](#ERC1967Proxy-_implementation--) function.

Additionally, delegation to the implementation can be triggered manually through the [`Proxy._fallback`](#Proxy-_fallback--) function, or to a
different contract through the [`Proxy._delegate`](#Proxy-_delegate-address-) function.

The success and return data of the delegated call will be returned back to the caller of the proxy.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [_delegate(implementation)](#Proxy-_delegate-address-)
- [_implementation()](#Proxy-_implementation--)
- [_fallback()](#Proxy-_fallback--)
- [fallback()](#Proxy-fallback--)
</div>
</div>

<a id="Proxy-_delegate-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_delegate(address implementation)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Proxy-_delegate-address-">#</a>
</div>
</div>
<div className="px-4">

Delegates the current call to `implementation`.

This function does not return to its internal call site, it will return directly to the external caller.

</div>
</div>

<a id="Proxy-_implementation--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_implementation() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Proxy-_implementation--">#</a>
</div>
</div>
<div className="px-4">

This is a virtual function that should be overridden so it returns the address to which the fallback
function and [`Proxy._fallback`](#Proxy-_fallback--) should delegate.

</div>
</div>

<a id="Proxy-_fallback--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_fallback()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Proxy-_fallback--">#</a>
</div>
</div>
<div className="px-4">

Delegates the current call to the address returned by `_implementation()`.

This function does not return to its internal call site, it will return directly to the external caller.

</div>
</div>

<a id="Proxy-fallback--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">fallback()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">external</p>
<a className="peer" data-card href="#Proxy-fallback--">#</a>
</div>
</div>
<div className="px-4">

Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
function in the contract matches the call data.

</div>
</div>

<a id="BeaconProxy"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `BeaconProxy` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/beacon/BeaconProxy.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
```

This contract implements a proxy that gets the implementation address for each call from an [`UpgradeableBeacon`](#UpgradeableBeacon).

The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
[ERC-1967](https://eips.ethereum.org/EIPS/eip-1967) so that it can be accessed externally.

<Callout type="warn">
Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
the beacon to not upgrade the implementation maliciously.
</Callout>

<Callout type="warn">
Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
an inconsistent state where the beacon storage slot does not match the beacon address.
</Callout>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [constructor(beacon, data)](#BeaconProxy-constructor-address-bytes-)
- [_implementation()](#BeaconProxy-_implementation--)
- [_getBeacon()](#BeaconProxy-_getBeacon--)
<details>
<summary>Proxy</summary>

- [_delegate(implementation)](#Proxy-_delegate-address-)
- [_fallback()](#Proxy-_fallback--)
- [fallback()](#Proxy-fallback--)

</details>
</div>
</div>

<a id="BeaconProxy-constructor-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">constructor(address beacon, bytes data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#BeaconProxy-constructor-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Initializes the proxy with `beacon`.

If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
constructor.

Requirements:

- `beacon` must be a contract with the interface [`IBeacon`](#IBeacon).
- If `data` is empty, `msg.value` must be zero.

</div>
</div>

<a id="BeaconProxy-_implementation--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_implementation() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#BeaconProxy-_implementation--">#</a>
</div>
</div>
<div className="px-4">

Returns the current implementation address of the associated beacon.

</div>
</div>

<a id="BeaconProxy-_getBeacon--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_getBeacon() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#BeaconProxy-_getBeacon--">#</a>
</div>
</div>
<div className="px-4">

Returns the beacon.

</div>
</div>

<a id="IBeacon"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `IBeacon` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/beacon/IBeacon.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
```

This is the interface that [`BeaconProxy`](#BeaconProxy) expects of its beacon.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [implementation()](#IBeacon-implementation--)
</div>
</div>

<a id="IBeacon-implementation--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">implementation() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">external</p>
<a className="peer" data-card href="#IBeacon-implementation--">#</a>
</div>
</div>
<div className="px-4">

Must return an address that can be used as a delegate call target.

[`UpgradeableBeacon`](#UpgradeableBeacon) will check that this address is a contract.

</div>
</div>

<a id="UpgradeableBeacon"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `UpgradeableBeacon` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/beacon/UpgradeableBeacon.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
```

This contract is used in conjunction with one or more instances of [`BeaconProxy`](#BeaconProxy) to determine their
implementation contract, which is where they will delegate all function calls.

An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [constructor(implementation_, initialOwner)](#UpgradeableBeacon-constructor-address-address-)
- [implementation()](#UpgradeableBeacon-implementation--)
- [upgradeTo(newImplementation)](#UpgradeableBeacon-upgradeTo-address-)
<details>
<summary>Ownable</summary>

- [owner()](#Ownable-owner--)
- [_checkOwner()](#Ownable-_checkOwner--)
- [renounceOwnership()](#Ownable-renounceOwnership--)
- [transferOwnership(newOwner)](#Ownable-transferOwnership-address-)
- [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-)

</details>
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Events</h3>
<div className="font-mono">
- [Upgraded(implementation)](#UpgradeableBeacon-Upgraded-address-)
<details>
<summary>Ownable</summary>

- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-)

</details>
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [BeaconInvalidImplementation(implementation)](#UpgradeableBeacon-BeaconInvalidImplementation-address-)
<details>
<summary>Ownable</summary>

- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-)
- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-)

</details>
</div>
</div>

<a id="UpgradeableBeacon-constructor-address-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">constructor(address implementation_, address initialOwner)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#UpgradeableBeacon-constructor-address-address-">#</a>
</div>
</div>
<div className="px-4">

Sets the address of the initial implementation, and the initial owner who can upgrade the beacon.

</div>
</div>

<a id="UpgradeableBeacon-implementation--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">implementation() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#UpgradeableBeacon-implementation--">#</a>
</div>
</div>
<div className="px-4">

Returns the current implementation address.

</div>
</div>

<a id="UpgradeableBeacon-upgradeTo-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">upgradeTo(address newImplementation)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#UpgradeableBeacon-upgradeTo-address-">#</a>
</div>
</div>
<div className="px-4">

Upgrades the beacon to a new implementation.

Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event.

Requirements:

- msg.sender must be the owner of the contract.
- `newImplementation` must be a contract.

</div>
</div>

<a id="UpgradeableBeacon-Upgraded-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">Upgraded(address indexed implementation)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">event</p>
<a className="peer" data-card href="#UpgradeableBeacon-Upgraded-address-">#</a>
</div>
</div>

<div className="px-4">

Emitted when the implementation returned by the beacon is changed.

</div>
</div>

<a id="UpgradeableBeacon-BeaconInvalidImplementation-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">BeaconInvalidImplementation(address implementation)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#UpgradeableBeacon-BeaconInvalidImplementation-address-">#</a>
</div>
</div>
<div className="px-4">

The `implementation` of the beacon is invalid.

</div>
</div>

<a id="ProxyAdmin"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `ProxyAdmin` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/transparent/ProxyAdmin.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
```

This is an auxiliary contract meant to be assigned as the admin of a [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy). For an
explanation of why you would want to use this see the documentation for [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy).

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [constructor(initialOwner)](#ProxyAdmin-constructor-address-)
- [upgradeAndCall(proxy, implementation, data)](#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-)
- [UPGRADE_INTERFACE_VERSION()](#ProxyAdmin-UPGRADE_INTERFACE_VERSION-string)
<details>
<summary>Ownable</summary>

- [owner()](#Ownable-owner--)
- [_checkOwner()](#Ownable-_checkOwner--)
- [renounceOwnership()](#Ownable-renounceOwnership--)
- [transferOwnership(newOwner)](#Ownable-transferOwnership-address-)
- [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-)

</details>
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Events</h3>
<div className="font-mono">
<details>
<summary>Ownable</summary>

- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-)

</details>
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
<details>
<summary>Ownable</summary>

- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-)
- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-)

</details>
</div>
</div>

<a id="ProxyAdmin-constructor-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">constructor(address initialOwner)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#ProxyAdmin-constructor-address-">#</a>
</div>
</div>
<div className="px-4">

Sets the initial owner who can perform upgrades.

</div>
</div>

<a id="ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">upgradeAndCall(contract ITransparentUpgradeableProxy proxy, address implementation, bytes data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Upgrades `proxy` to `implementation` and calls a function on the new implementation.
See [`TransparentUpgradeableProxy._dispatchUpgradeToAndCall`](#TransparentUpgradeableProxy-_dispatchUpgradeToAndCall--).

Requirements:

- This contract must be the admin of `proxy`.
- If `data` is empty, `msg.value` must be zero.

</div>
</div>

<a id="ProxyAdmin-UPGRADE_INTERFACE_VERSION-string"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">UPGRADE_INTERFACE_VERSION() → string</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#ProxyAdmin-UPGRADE_INTERFACE_VERSION-string">#</a>
</div>
</div>
<div className="px-4">

The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address,address)`
and `upgradeAndCall(address,address,bytes)` are present, and `upgrade` must be used if no function should be called,
while `upgradeAndCall` will invoke the `receive` function if the third argument is the empty byte string.
If the getter returns `"5.0.0"`, only `upgradeAndCall(address,address,bytes)` is present, and the third argument must
be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
during an upgrade.

</div>
</div>

<a id="ITransparentUpgradeableProxy"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `ITransparentUpgradeableProxy` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
```

Interface for [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy). In order to implement transparency, [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy)
does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch
mechanism. The compiler is unaware that these functions are implemented by [`TransparentUpgradeableProxy`](#TransparentUpgradeableProxy) and will not
include them in the ABI so this interface must be used to interact with it.

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [upgradeToAndCall(newImplementation, data)](#ITransparentUpgradeableProxy-upgradeToAndCall-address-bytes-)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Events</h3>
<div className="font-mono">
<details>
<summary>IERC1967</summary>

- [Upgraded(implementation)](#IERC1967-Upgraded-address-)
- [AdminChanged(previousAdmin, newAdmin)](#IERC1967-AdminChanged-address-address-)
- [BeaconUpgraded(beacon)](#IERC1967-BeaconUpgraded-address-)

</details>
</div>
</div>

<a id="ITransparentUpgradeableProxy-upgradeToAndCall-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">upgradeToAndCall(address newImplementation, bytes data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">external</p>
<a className="peer" data-card href="#ITransparentUpgradeableProxy-upgradeToAndCall-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

See [`UUPSUpgradeable.upgradeToAndCall`](#UUPSUpgradeable-upgradeToAndCall-address-bytes-)

</div>
</div>

<a id="TransparentUpgradeableProxy"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `TransparentUpgradeableProxy` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
```

This contract implements a proxy that is upgradeable through an associated [`ProxyAdmin`](#ProxyAdmin) instance.

To avoid [proxy selector
clashing](https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357), which can potentially be used in an attack, this contract uses the
[transparent proxy pattern](https://blog.openzeppelin.com/the-transparent-proxy-pattern/). This pattern implies two
things that go hand in hand:

1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
that call matches the [`ITransparentUpgradeableProxy.upgradeToAndCall`](#ITransparentUpgradeableProxy-upgradeToAndCall-address-bytes-) function exposed by the proxy itself.
2. If the admin calls the proxy, it can call the `upgradeToAndCall` function, but any other call won't be forwarded to
the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
the proxy admin cannot fallback to the target implementation.

These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
call a function from the proxy implementation. For this reason, the proxy deploys an instance of [`ProxyAdmin`](#ProxyAdmin) and
allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.

<Callout>
The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
implementation.
</Callout>

<Callout>
This proxy does not inherit from [`Context`](/contracts/5.x/api/utils#Context) deliberately. The [`ProxyAdmin`](#ProxyAdmin) of this contract won't send a
meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
</Callout>

<Callout type="warn">
This contract avoids unnecessary storage reads by setting the admin only during construction as an
immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
undesirable state where the admin slot is different from the actual admin. Relying on the value of the admin slot
is generally fine if the implementation is trusted.
</Callout>

<Callout type="warn">
It is not recommended to extend this contract to add additional external functions. If you do so, the
compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
function and the functions declared in [`ITransparentUpgradeableProxy`](#ITransparentUpgradeableProxy) will be resolved in favor of the new one. This
could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
</Callout>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [constructor(_logic, initialOwner, _data)](#TransparentUpgradeableProxy-constructor-address-address-bytes-)
- [_proxyAdmin()](#TransparentUpgradeableProxy-_proxyAdmin--)
- [_fallback()](#TransparentUpgradeableProxy-_fallback--)
<details>
<summary>ERC1967Proxy</summary>

- [_implementation()](#ERC1967Proxy-_implementation--)
- [_unsafeAllowUninitialized()](#ERC1967Proxy-_unsafeAllowUninitialized--)

</details>
<details>
<summary>Proxy</summary>

- [_delegate(implementation)](#Proxy-_delegate-address-)
- [fallback()](#Proxy-fallback--)

</details>
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [ProxyDeniedAdminAccess()](#TransparentUpgradeableProxy-ProxyDeniedAdminAccess--)
<details>
<summary>ERC1967Proxy</summary>

- [ERC1967ProxyUninitialized()](#ERC1967Proxy-ERC1967ProxyUninitialized--)

</details>
</div>
</div>

<a id="TransparentUpgradeableProxy-constructor-address-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">constructor(address _logic, address initialOwner, bytes _data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#TransparentUpgradeableProxy-constructor-address-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Initializes an upgradeable proxy managed by an instance of a [`ProxyAdmin`](#ProxyAdmin) with an `initialOwner`,
backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
[`ERC1967Proxy.constructor`](#ERC1967Proxy-constructor-address-bytes-).

</div>
</div>

<a id="TransparentUpgradeableProxy-_proxyAdmin--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_proxyAdmin() → address</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#TransparentUpgradeableProxy-_proxyAdmin--">#</a>
</div>
</div>
<div className="px-4">

Returns the admin of this proxy.

</div>
</div>

<a id="TransparentUpgradeableProxy-_fallback--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_fallback()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#TransparentUpgradeableProxy-_fallback--">#</a>
</div>
</div>
<div className="px-4">

If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.

</div>
</div>

<a id="TransparentUpgradeableProxy-ProxyDeniedAdminAccess--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">ProxyDeniedAdminAccess()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#TransparentUpgradeableProxy-ProxyDeniedAdminAccess--">#</a>
</div>
</div>
<div className="px-4">

The proxy caller is the current admin, and can't fallback to the proxy target.

</div>
</div>

<a id="Initializable"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `Initializable` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/utils/Initializable.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
```

This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
function so it can only be called once. The [`Initializable.initializer`](#Initializable-initializer--) modifier provided by this contract will have this effect.

The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
case an upgrade adds a module that needs to be initialized.

For example:

[.hljs-theme-light.nopadding]
```solidity
contract MyToken is ERC20Upgradeable {
    function initialize() initializer public {
        __ERC20_init("MyToken", "MTK");
    }
}

contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
    function initializeV2() reinitializer(2) public {
        __ERC20Permit_init("MyToken");
    }
}
```

<Callout>
To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
possible by providing the encoded function call as the `_data` argument to [`ERC1967Proxy.constructor`](#ERC1967Proxy-constructor-address-bytes-).
</Callout>

<Callout type="warn">
When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
</Callout>

<Callout type="warn">
Avoid leaving a contract uninitialized.

An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
the [`Initializable._disableInitializers`](#Initializable-_disableInitializers--) function in the constructor to automatically lock it when it is deployed:

[.hljs-theme-light.nopadding]
```
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
    _disableInitializers();
}
```
</Callout>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Modifiers</h3>
<div className="font-mono">
- [initializer()](#Initializable-initializer--)
- [reinitializer(version)](#Initializable-reinitializer-uint64-)
- [onlyInitializing()](#Initializable-onlyInitializing--)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [_checkInitializing()](#Initializable-_checkInitializing--)
- [_disableInitializers()](#Initializable-_disableInitializers--)
- [_getInitializedVersion()](#Initializable-_getInitializedVersion--)
- [_isInitializing()](#Initializable-_isInitializing--)
- [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Events</h3>
<div className="font-mono">
- [Initialized(version)](#Initializable-Initialized-uint64-)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [InvalidInitialization()](#Initializable-InvalidInitialization--)
- [NotInitializing()](#Initializable-NotInitializing--)
</div>
</div>

<a id="Initializable-initializer--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">initializer()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-initializer--">#</a>
</div>
</div>

<div className="px-4">

A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
`onlyInitializing` functions can be used to initialize parent contracts.

Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
production.

Emits an [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event.

</div>
</div>

<a id="Initializable-reinitializer-uint64-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">reinitializer(uint64 version)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-reinitializer-uint64-">#</a>
</div>
</div>

<div className="px-4">

A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
used to initialize parent contracts.

A reinitializer may be used after the original initialization step. This is essential to configure modules that
are added through upgrades and that require initialization.

When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
cannot be nested. If one is invoked in the context of another, execution will revert.

Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
a contract, executing them in the right order is up to the developer or operator.

<Callout type="warn">
Setting the version to 2**64 - 1 will prevent any future reinitialization.
</Callout>

Emits an [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event.

</div>
</div>

<a id="Initializable-onlyInitializing--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">onlyInitializing()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-onlyInitializing--">#</a>
</div>
</div>

<div className="px-4">

Modifier to protect an initialization function so that it can only be invoked by functions with the
[`Initializable.initializer`](#Initializable-initializer--) and [`Initializable.reinitializer`](#Initializable-reinitializer-uint64-) modifiers, directly or indirectly.

</div>
</div>

<a id="Initializable-_checkInitializing--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_checkInitializing()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-_checkInitializing--">#</a>
</div>
</div>
<div className="px-4">

Reverts if the contract is not in an initializing state. See [`Initializable.onlyInitializing`](#Initializable-onlyInitializing--).

</div>
</div>

<a id="Initializable-_disableInitializers--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_disableInitializers()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-_disableInitializers--">#</a>
</div>
</div>
<div className="px-4">

Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
to any version. It is recommended to use this to lock implementation contracts that are designed to be called
through proxies.

Emits an [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event the first time it is successfully executed.

</div>
</div>

<a id="Initializable-_getInitializedVersion--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_getInitializedVersion() → uint64</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-_getInitializedVersion--">#</a>
</div>
</div>
<div className="px-4">

Returns the highest version that has been initialized. See [`Initializable.reinitializer`](#Initializable-reinitializer-uint64-).

</div>
</div>

<a id="Initializable-_isInitializing--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_isInitializing() → bool</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-_isInitializing--">#</a>
</div>
</div>
<div className="px-4">

Returns `true` if the contract is currently initializing. See [`Initializable.onlyInitializing`](#Initializable-onlyInitializing--).

</div>
</div>

<a id="Initializable-_initializableStorageSlot--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_initializableStorageSlot() → bytes32</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#Initializable-_initializableStorageSlot--">#</a>
</div>
</div>
<div className="px-4">

Pointer to storage slot. Allows integrators to override it with a custom storage location.

<Callout>
Consider following the ERC-7201 formula to derive storage locations.
</Callout>

</div>
</div>

<a id="Initializable-Initialized-uint64-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">Initialized(uint64 version)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">event</p>
<a className="peer" data-card href="#Initializable-Initialized-uint64-">#</a>
</div>
</div>

<div className="px-4">

Triggered when the contract has been initialized or reinitialized.

</div>
</div>

<a id="Initializable-InvalidInitialization--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">InvalidInitialization()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#Initializable-InvalidInitialization--">#</a>
</div>
</div>
<div className="px-4">

The contract is already initialized.

</div>
</div>

<a id="Initializable-NotInitializing--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">NotInitializing()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#Initializable-NotInitializing--">#</a>
</div>
</div>
<div className="px-4">

The contract is not initializing.

</div>
</div>

<a id="UUPSUpgradeable"></a>

<div style={{marginTop: "4em"}} className="w-full flex flex-row items-center justify-between">

## `UUPSUpgradeable` 

<a target="_blank" style={{marginTop: "1.5em"}} href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.6.1/contracts/proxy/utils/UUPSUpgradeable.sol">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github-icon lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
</a>

</div>

```solidity
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
```

An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
[`ERC1967Proxy`](#ERC1967Proxy), when this contract is set as the implementation behind such a proxy.

A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
`UUPSUpgradeable` with a custom implementation of upgrades.

The [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-) function must be overridden to include access restriction to the upgrade mechanism.

@custom:stateless

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Modifiers</h3>
<div className="font-mono">
- [onlyProxy()](#UUPSUpgradeable-onlyProxy--)
- [notDelegated()](#UUPSUpgradeable-notDelegated--)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Functions</h3>
<div className="font-mono">
- [proxiableUUID()](#UUPSUpgradeable-proxiableUUID--)
- [upgradeToAndCall(newImplementation, data)](#UUPSUpgradeable-upgradeToAndCall-address-bytes-)
- [_checkProxy()](#UUPSUpgradeable-_checkProxy--)
- [_checkNotDelegated()](#UUPSUpgradeable-_checkNotDelegated--)
- [_authorizeUpgrade(newImplementation)](#UUPSUpgradeable-_authorizeUpgrade-address-)
- [UPGRADE_INTERFACE_VERSION()](#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string)
</div>
</div>

<div className="bg-secondary p-4 rounded-md mb-6">
<h3 style={{ marginTop: "0"}}>Errors</h3>
<div className="font-mono">
- [UUPSUnauthorizedCallContext()](#UUPSUpgradeable-UUPSUnauthorizedCallContext--)
- [UUPSUnsupportedProxiableUUID(slot)](#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-)
</div>
</div>

<a id="UUPSUpgradeable-onlyProxy--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">onlyProxy()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#UUPSUpgradeable-onlyProxy--">#</a>
</div>
</div>

<div className="px-4">

Check that the execution is being performed through a delegatecall call and that the execution context is
a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
fail.

</div>
</div>

<a id="UUPSUpgradeable-notDelegated--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">notDelegated()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#UUPSUpgradeable-notDelegated--">#</a>
</div>
</div>

<div className="px-4">

Check that the execution is not being performed through a delegate call. This allows a function to be
callable on the implementing contract but not through proxies.

</div>
</div>

<a id="UUPSUpgradeable-proxiableUUID--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">proxiableUUID() → bytes32</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">external</p>
<a className="peer" data-card href="#UUPSUpgradeable-proxiableUUID--">#</a>
</div>
</div>
<div className="px-4">

Implementation of the ERC-1822 [`UUPSUpgradeable.proxiableUUID`](#UUPSUpgradeable-proxiableUUID--) function. This returns the storage slot used by the
implementation. It is used to validate the implementation's compatibility when performing an upgrade.

<Callout type="warn">
A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
</Callout>

</div>
</div>

<a id="UUPSUpgradeable-upgradeToAndCall-address-bytes-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">upgradeToAndCall(address newImplementation, bytes data)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#UUPSUpgradeable-upgradeToAndCall-address-bytes-">#</a>
</div>
</div>
<div className="px-4">

Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
encoded in `data`.

Calls [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-).

Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event.

</div>
</div>

<a id="UUPSUpgradeable-_checkProxy--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_checkProxy()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#UUPSUpgradeable-_checkProxy--">#</a>
</div>
</div>
<div className="px-4">

Reverts if the execution is not performed via delegatecall or the execution
context is not of a proxy with an ERC-1967 compliant implementation pointing to self.

</div>
</div>

<a id="UUPSUpgradeable-_checkNotDelegated--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_checkNotDelegated()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#UUPSUpgradeable-_checkNotDelegated--">#</a>
</div>
</div>
<div className="px-4">

Reverts if the execution is performed via delegatecall.
See [`UUPSUpgradeable.notDelegated`](#UUPSUpgradeable-notDelegated--).

</div>
</div>

<a id="UUPSUpgradeable-_authorizeUpgrade-address-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">_authorizeUpgrade(address newImplementation)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">internal</p>
<a className="peer" data-card href="#UUPSUpgradeable-_authorizeUpgrade-address-">#</a>
</div>
</div>
<div className="px-4">

Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
[`ERC1967Utils.upgradeToAndCall`](#ERC1967Utils-upgradeToAndCall-address-bytes-).

Normally, this function will use an [access control](/contracts/5.x/api/access) modifier such as [`Ownable.onlyOwner`](/contracts/5.x/api/access#Ownable-onlyOwner--).

```solidity
function _authorizeUpgrade(address) internal onlyOwner {}
```

</div>
</div>

<a id="UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">UPGRADE_INTERFACE_VERSION() → string</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">public</p>
<a className="peer" data-card href="#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string">#</a>
</div>
</div>
<div className="px-4">

The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
during an upgrade.

</div>
</div>

<a id="UUPSUpgradeable-UUPSUnauthorizedCallContext--"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">UUPSUnauthorizedCallContext()</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#UUPSUpgradeable-UUPSUnauthorizedCallContext--">#</a>
</div>
</div>
<div className="px-4">

The call is from an unauthorized context.

</div>
</div>

<a id="UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-"></a>

<div className="border rounded-md mb-4">
<div className="bg-secondary flex w-full justify-between px-4">
<p className="font-bold text-sm font-mono">UUPSUnsupportedProxiableUUID(bytes32 slot)</p>
<div className="flex flex-row items-center gap-2">
<p className="font-light text-sm">error</p>
<a className="peer" data-card href="#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-">#</a>
</div>
</div>
<div className="px-4">

The storage `slot` is unsupported as a UUID.

</div>
</div>

