proxy.adoc 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. :github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
  2. :Proxy: pass:normal[xref:proxy.adoc#Proxy[`Proxy`]]
  3. :ERC1967Utils: pass:normal[xref:proxy.adoc#ERC1967Utils[`ERC1967Utils`]]
  4. :ERC1967Proxy: pass:normal[xref:proxy.adoc#ERC1967Proxy[`ERC1967Proxy`]]
  5. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  6. :UUPSUpgradeable: pass:normal[xref:proxy.adoc#UUPSUpgradeable[`UUPSUpgradeable`]]
  7. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  8. :UpgradeableBeacon: pass:normal[xref:proxy.adoc#UpgradeableBeacon[`UpgradeableBeacon`]]
  9. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  10. :Clones: pass:normal[xref:proxy.adoc#Clones[`Clones`]]
  11. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  12. :ERC1967Proxy: pass:normal[xref:proxy.adoc#ERC1967Proxy[`ERC1967Proxy`]]
  13. :UUPSUpgradeable: pass:normal[xref:proxy.adoc#UUPSUpgradeable[`UUPSUpgradeable`]]
  14. :xref-UUPSUpgradeable-_authorizeUpgrade-address-: xref:proxy.adoc#UUPSUpgradeable-_authorizeUpgrade-address-
  15. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  16. :UUPSUpgradeable: pass:normal[xref:proxy.adoc#UUPSUpgradeable[`UUPSUpgradeable`]]
  17. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  18. :xref-Proxy-_implementation--: xref:proxy.adoc#Proxy-_implementation--
  19. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  20. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  21. :xref-ERC1967Proxy-constructor-address-bytes-: xref:proxy.adoc#ERC1967Proxy-constructor-address-bytes-
  22. :xref-ERC1967Proxy-_implementation--: xref:proxy.adoc#ERC1967Proxy-_implementation--
  23. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  24. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  25. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  26. :xref-ERC1967Utils-getImplementation--: xref:proxy.adoc#ERC1967Utils-getImplementation--
  27. :xref-ERC1967Utils-upgradeToAndCall-address-bytes-: xref:proxy.adoc#ERC1967Utils-upgradeToAndCall-address-bytes-
  28. :xref-ERC1967Utils-getAdmin--: xref:proxy.adoc#ERC1967Utils-getAdmin--
  29. :xref-ERC1967Utils-changeAdmin-address-: xref:proxy.adoc#ERC1967Utils-changeAdmin-address-
  30. :xref-ERC1967Utils-getBeacon--: xref:proxy.adoc#ERC1967Utils-getBeacon--
  31. :xref-ERC1967Utils-upgradeBeaconToAndCall-address-bytes-: xref:proxy.adoc#ERC1967Utils-upgradeBeaconToAndCall-address-bytes-
  32. :xref-ERC1967Utils-Upgraded-address-: xref:proxy.adoc#ERC1967Utils-Upgraded-address-
  33. :xref-ERC1967Utils-AdminChanged-address-address-: xref:proxy.adoc#ERC1967Utils-AdminChanged-address-address-
  34. :xref-ERC1967Utils-BeaconUpgraded-address-: xref:proxy.adoc#ERC1967Utils-BeaconUpgraded-address-
  35. :xref-ERC1967Utils-ERC1967InvalidImplementation-address-: xref:proxy.adoc#ERC1967Utils-ERC1967InvalidImplementation-address-
  36. :xref-ERC1967Utils-ERC1967InvalidAdmin-address-: xref:proxy.adoc#ERC1967Utils-ERC1967InvalidAdmin-address-
  37. :xref-ERC1967Utils-ERC1967InvalidBeacon-address-: xref:proxy.adoc#ERC1967Utils-ERC1967InvalidBeacon-address-
  38. :xref-ERC1967Utils-ERC1967NonPayable--: xref:proxy.adoc#ERC1967Utils-ERC1967NonPayable--
  39. :IERC1967-Upgraded: pass:normal[xref:interfaces.adoc#IERC1967-Upgraded-address-[`IERC1967.Upgraded`]]
  40. :IERC1967-AdminChanged: pass:normal[xref:interfaces.adoc#IERC1967-AdminChanged-address-address-[`IERC1967.AdminChanged`]]
  41. :IERC1967-BeaconUpgraded: pass:normal[xref:interfaces.adoc#IERC1967-BeaconUpgraded-address-[`IERC1967.BeaconUpgraded`]]
  42. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  43. :ProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin[`ProxyAdmin`]]
  44. :ITransparentUpgradeableProxy-upgradeToAndCall: pass:normal[xref:proxy.adoc#ITransparentUpgradeableProxy-upgradeToAndCall-address-bytes-[`ITransparentUpgradeableProxy.upgradeToAndCall`]]
  45. :ProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin[`ProxyAdmin`]]
  46. :Context: pass:normal[xref:utils.adoc#Context[`Context`]]
  47. :ProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin[`ProxyAdmin`]]
  48. :ITransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#ITransparentUpgradeableProxy[`ITransparentUpgradeableProxy`]]
  49. :xref-TransparentUpgradeableProxy-constructor-address-address-bytes-: xref:proxy.adoc#TransparentUpgradeableProxy-constructor-address-address-bytes-
  50. :xref-TransparentUpgradeableProxy-_proxyAdmin--: xref:proxy.adoc#TransparentUpgradeableProxy-_proxyAdmin--
  51. :xref-TransparentUpgradeableProxy-_fallback--: xref:proxy.adoc#TransparentUpgradeableProxy-_fallback--
  52. :xref-ERC1967Proxy-_implementation--: xref:proxy.adoc#ERC1967Proxy-_implementation--
  53. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  54. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  55. :xref-TransparentUpgradeableProxy-ProxyDeniedAdminAccess--: xref:proxy.adoc#TransparentUpgradeableProxy-ProxyDeniedAdminAccess--
  56. :ProxyAdmin: pass:normal[xref:proxy.adoc#ProxyAdmin[`ProxyAdmin`]]
  57. :ERC1967Proxy-constructor: pass:normal[xref:proxy.adoc#ERC1967Proxy-constructor-address-bytes-[`ERC1967Proxy.constructor`]]
  58. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  59. :TransparentUpgradeableProxy: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy[`TransparentUpgradeableProxy`]]
  60. :xref-ProxyAdmin-constructor-address-: xref:proxy.adoc#ProxyAdmin-constructor-address-
  61. :xref-ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-: xref:proxy.adoc#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-
  62. :xref-Ownable-owner--: xref:access.adoc#Ownable-owner--
  63. :xref-Ownable-_checkOwner--: xref:access.adoc#Ownable-_checkOwner--
  64. :xref-Ownable-renounceOwnership--: xref:access.adoc#Ownable-renounceOwnership--
  65. :xref-Ownable-transferOwnership-address-: xref:access.adoc#Ownable-transferOwnership-address-
  66. :xref-Ownable-_transferOwnership-address-: xref:access.adoc#Ownable-_transferOwnership-address-
  67. :xref-Ownable-OwnershipTransferred-address-address-: xref:access.adoc#Ownable-OwnershipTransferred-address-address-
  68. :xref-Ownable-OwnableUnauthorizedAccount-address-: xref:access.adoc#Ownable-OwnableUnauthorizedAccount-address-
  69. :xref-Ownable-OwnableInvalidOwner-address-: xref:access.adoc#Ownable-OwnableInvalidOwner-address-
  70. :TransparentUpgradeableProxy-_dispatchUpgradeToAndCall: pass:normal[xref:proxy.adoc#TransparentUpgradeableProxy-_dispatchUpgradeToAndCall--[`TransparentUpgradeableProxy._dispatchUpgradeToAndCall`]]
  71. :UpgradeableBeacon: pass:normal[xref:proxy.adoc#UpgradeableBeacon[`UpgradeableBeacon`]]
  72. :xref-BeaconProxy-constructor-address-bytes-: xref:proxy.adoc#BeaconProxy-constructor-address-bytes-
  73. :xref-BeaconProxy-_implementation--: xref:proxy.adoc#BeaconProxy-_implementation--
  74. :xref-BeaconProxy-_getBeacon--: xref:proxy.adoc#BeaconProxy-_getBeacon--
  75. :xref-Proxy-_delegate-address-: xref:proxy.adoc#Proxy-_delegate-address-
  76. :xref-Proxy-_fallback--: xref:proxy.adoc#Proxy-_fallback--
  77. :xref-Proxy-fallback--: xref:proxy.adoc#Proxy-fallback--
  78. :IBeacon: pass:normal[xref:proxy.adoc#IBeacon[`IBeacon`]]
  79. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  80. :xref-IBeacon-implementation--: xref:proxy.adoc#IBeacon-implementation--
  81. :UpgradeableBeacon: pass:normal[xref:proxy.adoc#UpgradeableBeacon[`UpgradeableBeacon`]]
  82. :BeaconProxy: pass:normal[xref:proxy.adoc#BeaconProxy[`BeaconProxy`]]
  83. :xref-UpgradeableBeacon-constructor-address-address-: xref:proxy.adoc#UpgradeableBeacon-constructor-address-address-
  84. :xref-UpgradeableBeacon-implementation--: xref:proxy.adoc#UpgradeableBeacon-implementation--
  85. :xref-UpgradeableBeacon-upgradeTo-address-: xref:proxy.adoc#UpgradeableBeacon-upgradeTo-address-
  86. :xref-Ownable-owner--: xref:access.adoc#Ownable-owner--
  87. :xref-Ownable-_checkOwner--: xref:access.adoc#Ownable-_checkOwner--
  88. :xref-Ownable-renounceOwnership--: xref:access.adoc#Ownable-renounceOwnership--
  89. :xref-Ownable-transferOwnership-address-: xref:access.adoc#Ownable-transferOwnership-address-
  90. :xref-Ownable-_transferOwnership-address-: xref:access.adoc#Ownable-_transferOwnership-address-
  91. :xref-UpgradeableBeacon-Upgraded-address-: xref:proxy.adoc#UpgradeableBeacon-Upgraded-address-
  92. :xref-Ownable-OwnershipTransferred-address-address-: xref:access.adoc#Ownable-OwnershipTransferred-address-address-
  93. :xref-UpgradeableBeacon-BeaconInvalidImplementation-address-: xref:proxy.adoc#UpgradeableBeacon-BeaconInvalidImplementation-address-
  94. :xref-Ownable-OwnableUnauthorizedAccount-address-: xref:access.adoc#Ownable-OwnableUnauthorizedAccount-address-
  95. :xref-Ownable-OwnableInvalidOwner-address-: xref:access.adoc#Ownable-OwnableInvalidOwner-address-
  96. :xref-Clones-clone-address-: xref:proxy.adoc#Clones-clone-address-
  97. :xref-Clones-cloneDeterministic-address-bytes32-: xref:proxy.adoc#Clones-cloneDeterministic-address-bytes32-
  98. :xref-Clones-predictDeterministicAddress-address-bytes32-address-: xref:proxy.adoc#Clones-predictDeterministicAddress-address-bytes32-address-
  99. :xref-Clones-predictDeterministicAddress-address-bytes32-: xref:proxy.adoc#Clones-predictDeterministicAddress-address-bytes32-
  100. :xref-Clones-ERC1167FailedCreateClone--: xref:proxy.adoc#Clones-ERC1167FailedCreateClone--
  101. :Clones-cloneDeterministic: pass:normal[xref:proxy.adoc#Clones-cloneDeterministic-address-bytes32-[`Clones.cloneDeterministic`]]
  102. :Clones-cloneDeterministic: pass:normal[xref:proxy.adoc#Clones-cloneDeterministic-address-bytes32-[`Clones.cloneDeterministic`]]
  103. :ERC1967Proxy-constructor: pass:normal[xref:proxy.adoc#ERC1967Proxy-constructor-address-bytes-[`ERC1967Proxy.constructor`]]
  104. :xref-Initializable-initializer--: xref:proxy.adoc#Initializable-initializer--
  105. :xref-Initializable-reinitializer-uint64-: xref:proxy.adoc#Initializable-reinitializer-uint64-
  106. :xref-Initializable-onlyInitializing--: xref:proxy.adoc#Initializable-onlyInitializing--
  107. :xref-Initializable-_checkInitializing--: xref:proxy.adoc#Initializable-_checkInitializing--
  108. :xref-Initializable-_disableInitializers--: xref:proxy.adoc#Initializable-_disableInitializers--
  109. :xref-Initializable-_getInitializedVersion--: xref:proxy.adoc#Initializable-_getInitializedVersion--
  110. :xref-Initializable-_isInitializing--: xref:proxy.adoc#Initializable-_isInitializing--
  111. :xref-Initializable-Initialized-uint64-: xref:proxy.adoc#Initializable-Initialized-uint64-
  112. :xref-Initializable-InvalidInitialization--: xref:proxy.adoc#Initializable-InvalidInitialization--
  113. :xref-Initializable-NotInitializing--: xref:proxy.adoc#Initializable-NotInitializing--
  114. :ERC1967Proxy: pass:normal[xref:proxy.adoc#ERC1967Proxy[`ERC1967Proxy`]]
  115. :xref-UUPSUpgradeable-onlyProxy--: xref:proxy.adoc#UUPSUpgradeable-onlyProxy--
  116. :xref-UUPSUpgradeable-notDelegated--: xref:proxy.adoc#UUPSUpgradeable-notDelegated--
  117. :xref-UUPSUpgradeable-proxiableUUID--: xref:proxy.adoc#UUPSUpgradeable-proxiableUUID--
  118. :xref-UUPSUpgradeable-upgradeToAndCall-address-bytes-: xref:proxy.adoc#UUPSUpgradeable-upgradeToAndCall-address-bytes-
  119. :xref-UUPSUpgradeable-_checkProxy--: xref:proxy.adoc#UUPSUpgradeable-_checkProxy--
  120. :xref-UUPSUpgradeable-_checkNotDelegated--: xref:proxy.adoc#UUPSUpgradeable-_checkNotDelegated--
  121. :xref-UUPSUpgradeable-_authorizeUpgrade-address-: xref:proxy.adoc#UUPSUpgradeable-_authorizeUpgrade-address-
  122. :xref-UUPSUpgradeable-UUPSUnauthorizedCallContext--: xref:proxy.adoc#UUPSUpgradeable-UUPSUnauthorizedCallContext--
  123. :xref-UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-: xref:proxy.adoc#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-
  124. :Ownable-onlyOwner: pass:normal[xref:access.adoc#Ownable-onlyOwner--[`Ownable.onlyOwner`]]
  125. = Proxies
  126. [.readme-notice]
  127. NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/proxy
  128. 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 xref:upgrades-plugins::proxies.adoc[Proxy Upgrade Pattern] page.
  129. Most of the proxies below are built on an abstract base contract.
  130. - {Proxy}: Abstract contract implementing the core delegation functionality.
  131. In order to avoid clashes with the storage variables of the implementation contract behind a proxy, we use https://eips.ethereum.org/EIPS/eip-1967[EIP1967] storage slots.
  132. - {ERC1967Utils}: Internal functions to get and set the storage slots defined in EIP1967.
  133. - {ERC1967Proxy}: A proxy using EIP1967 storage slots. Not upgradeable by default.
  134. There are two alternative ways to add upgradeability to an ERC1967 proxy. Their differences are explained below in <<transparent-vs-uups>>.
  135. - {TransparentUpgradeableProxy}: A proxy with a built-in immutable admin and upgrade interface.
  136. - {UUPSUpgradeable}: An upgradeability mechanism to be included in the implementation contract.
  137. 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 xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins] for Truffle and Hardhat.
  138. A different family of proxies are beacon proxies. This pattern, popularized by Dharma, allows multiple proxies to be upgraded to a different implementation in a single transaction.
  139. - {BeaconProxy}: A proxy that retrieves its implementation from a beacon contract.
  140. - {UpgradeableBeacon}: A beacon contract with a built in admin that can upgrade the {BeaconProxy} pointing to it.
  141. In this pattern, the proxy contract doesn't hold the implementation address in storage like an ERC1967 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.
  142. 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.
  143. - {Clones}: A library that can deploy cheap minimal non-upgradeable proxies.
  144. [[transparent-vs-uups]]
  145. == Transparent vs UUPS Proxies
  146. The original proxies included in OpenZeppelin followed the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[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 https://eips.ethereum.org/EIPS/eip-1822[EIP1822], which first documented the pattern.
  147. 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} is more expensive to deploy than what is possible with UUPS proxies.
  148. UUPS proxies are implemented using an {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} contract comes in. Inheriting from it (and overriding the {xref-UUPSUpgradeable-_authorizeUpgrade-address-}[`_authorizeUpgrade`] function with the relevant access control mechanism) will turn your contract into a UUPS compliant implementation.
  149. Note that since both proxies use the same storage slot for the implementation address, using a UUPS compliant implementation with a {TransparentUpgradeableProxy} might allow non-admins to perform upgrade operations.
  150. By default, the upgrade functionality included in {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:
  151. - Adding a flag mechanism in the implementation that will disable the upgrade function when triggered.
  152. - 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.
  153. The current implementation of this security mechanism uses https://eips.ethereum.org/EIPS/eip-1822[EIP1822] 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 `ERC1822` interface.
  154. == Core
  155. :_delegate: pass:normal[xref:#Proxy-_delegate-address-[`++_delegate++`]]
  156. :_implementation: pass:normal[xref:#Proxy-_implementation--[`++_implementation++`]]
  157. :_fallback: pass:normal[xref:#Proxy-_fallback--[`++_fallback++`]]
  158. :fallback: pass:normal[xref:#Proxy-fallback--[`++fallback++`]]
  159. [.contract]
  160. [[Proxy]]
  161. === `++Proxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/Proxy.sol[{github-icon},role=heading-link]
  162. [.hljs-theme-light.nopadding]
  163. ```solidity
  164. import "@openzeppelin/contracts/proxy/Proxy.sol";
  165. ```
  166. This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
  167. instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
  168. be specified by overriding the virtual {_implementation} function.
  169. Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
  170. different contract through the {_delegate} function.
  171. The success and return data of the delegated call will be returned back to the caller of the proxy.
  172. [.contract-index]
  173. .Functions
  174. --
  175. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  176. * {xref-Proxy-_implementation--}[`++_implementation()++`]
  177. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  178. * {xref-Proxy-fallback--}[`++fallback()++`]
  179. --
  180. [.contract-item]
  181. [[Proxy-_delegate-address-]]
  182. ==== `[.contract-item-name]#++_delegate++#++(address implementation)++` [.item-kind]#internal#
  183. Delegates the current call to `implementation`.
  184. This function does not return to its internal call site, it will return directly to the external caller.
  185. [.contract-item]
  186. [[Proxy-_implementation--]]
  187. ==== `[.contract-item-name]#++_implementation++#++() → address++` [.item-kind]#internal#
  188. This is a virtual function that should be overridden so it returns the address to which the fallback
  189. function and {_fallback} should delegate.
  190. [.contract-item]
  191. [[Proxy-_fallback--]]
  192. ==== `[.contract-item-name]#++_fallback++#++()++` [.item-kind]#internal#
  193. Delegates the current call to the address returned by `_implementation()`.
  194. This function does not return to its internal call site, it will return directly to the external caller.
  195. [.contract-item]
  196. [[Proxy-fallback--]]
  197. ==== `[.contract-item-name]#++fallback++#++()++` [.item-kind]#external#
  198. Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
  199. function in the contract matches the call data.
  200. == ERC1967
  201. :constructor: pass:normal[xref:#ERC1967Proxy-constructor-address-bytes-[`++constructor++`]]
  202. :_implementation: pass:normal[xref:#ERC1967Proxy-_implementation--[`++_implementation++`]]
  203. [.contract]
  204. [[ERC1967Proxy]]
  205. === `++ERC1967Proxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/ERC1967/ERC1967Proxy.sol[{github-icon},role=heading-link]
  206. [.hljs-theme-light.nopadding]
  207. ```solidity
  208. import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
  209. ```
  210. This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
  211. implementation address that can be changed. This address is stored in storage in the location specified by
  212. https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
  213. implementation behind the proxy.
  214. [.contract-index]
  215. .Functions
  216. --
  217. * {xref-ERC1967Proxy-constructor-address-bytes-}[`++constructor(implementation, _data)++`]
  218. * {xref-ERC1967Proxy-_implementation--}[`++_implementation()++`]
  219. [.contract-subindex-inherited]
  220. .Proxy
  221. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  222. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  223. * {xref-Proxy-fallback--}[`++fallback()++`]
  224. --
  225. [.contract-item]
  226. [[ERC1967Proxy-constructor-address-bytes-]]
  227. ==== `[.contract-item-name]#++constructor++#++(address implementation, bytes _data)++` [.item-kind]#public#
  228. Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
  229. If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
  230. encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
  231. Requirements:
  232. - If `data` is empty, `msg.value` must be zero.
  233. [.contract-item]
  234. [[ERC1967Proxy-_implementation--]]
  235. ==== `[.contract-item-name]#++_implementation++#++() → address++` [.item-kind]#internal#
  236. Returns the current implementation address.
  237. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
  238. the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
  239. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
  240. :Upgraded: pass:normal[xref:#ERC1967Utils-Upgraded-address-[`++Upgraded++`]]
  241. :AdminChanged: pass:normal[xref:#ERC1967Utils-AdminChanged-address-address-[`++AdminChanged++`]]
  242. :BeaconUpgraded: pass:normal[xref:#ERC1967Utils-BeaconUpgraded-address-[`++BeaconUpgraded++`]]
  243. :IMPLEMENTATION_SLOT: pass:normal[xref:#ERC1967Utils-IMPLEMENTATION_SLOT-bytes32[`++IMPLEMENTATION_SLOT++`]]
  244. :ERC1967InvalidImplementation: pass:normal[xref:#ERC1967Utils-ERC1967InvalidImplementation-address-[`++ERC1967InvalidImplementation++`]]
  245. :ERC1967InvalidAdmin: pass:normal[xref:#ERC1967Utils-ERC1967InvalidAdmin-address-[`++ERC1967InvalidAdmin++`]]
  246. :ERC1967InvalidBeacon: pass:normal[xref:#ERC1967Utils-ERC1967InvalidBeacon-address-[`++ERC1967InvalidBeacon++`]]
  247. :ERC1967NonPayable: pass:normal[xref:#ERC1967Utils-ERC1967NonPayable--[`++ERC1967NonPayable++`]]
  248. :getImplementation: pass:normal[xref:#ERC1967Utils-getImplementation--[`++getImplementation++`]]
  249. :upgradeToAndCall: pass:normal[xref:#ERC1967Utils-upgradeToAndCall-address-bytes-[`++upgradeToAndCall++`]]
  250. :ADMIN_SLOT: pass:normal[xref:#ERC1967Utils-ADMIN_SLOT-bytes32[`++ADMIN_SLOT++`]]
  251. :getAdmin: pass:normal[xref:#ERC1967Utils-getAdmin--[`++getAdmin++`]]
  252. :changeAdmin: pass:normal[xref:#ERC1967Utils-changeAdmin-address-[`++changeAdmin++`]]
  253. :BEACON_SLOT: pass:normal[xref:#ERC1967Utils-BEACON_SLOT-bytes32[`++BEACON_SLOT++`]]
  254. :getBeacon: pass:normal[xref:#ERC1967Utils-getBeacon--[`++getBeacon++`]]
  255. :upgradeBeaconToAndCall: pass:normal[xref:#ERC1967Utils-upgradeBeaconToAndCall-address-bytes-[`++upgradeBeaconToAndCall++`]]
  256. [.contract]
  257. [[ERC1967Utils]]
  258. === `++ERC1967Utils++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/ERC1967/ERC1967Utils.sol[{github-icon},role=heading-link]
  259. [.hljs-theme-light.nopadding]
  260. ```solidity
  261. import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
  262. ```
  263. This abstract contract provides getters and event emitting update functions for
  264. https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
  265. [.contract-index]
  266. .Functions
  267. --
  268. * {xref-ERC1967Utils-getImplementation--}[`++getImplementation()++`]
  269. * {xref-ERC1967Utils-upgradeToAndCall-address-bytes-}[`++upgradeToAndCall(newImplementation, data)++`]
  270. * {xref-ERC1967Utils-getAdmin--}[`++getAdmin()++`]
  271. * {xref-ERC1967Utils-changeAdmin-address-}[`++changeAdmin(newAdmin)++`]
  272. * {xref-ERC1967Utils-getBeacon--}[`++getBeacon()++`]
  273. * {xref-ERC1967Utils-upgradeBeaconToAndCall-address-bytes-}[`++upgradeBeaconToAndCall(newBeacon, data)++`]
  274. --
  275. [.contract-index]
  276. .Events
  277. --
  278. * {xref-ERC1967Utils-Upgraded-address-}[`++Upgraded(implementation)++`]
  279. * {xref-ERC1967Utils-AdminChanged-address-address-}[`++AdminChanged(previousAdmin, newAdmin)++`]
  280. * {xref-ERC1967Utils-BeaconUpgraded-address-}[`++BeaconUpgraded(beacon)++`]
  281. --
  282. [.contract-index]
  283. .Errors
  284. --
  285. * {xref-ERC1967Utils-ERC1967InvalidImplementation-address-}[`++ERC1967InvalidImplementation(implementation)++`]
  286. * {xref-ERC1967Utils-ERC1967InvalidAdmin-address-}[`++ERC1967InvalidAdmin(admin)++`]
  287. * {xref-ERC1967Utils-ERC1967InvalidBeacon-address-}[`++ERC1967InvalidBeacon(beacon)++`]
  288. * {xref-ERC1967Utils-ERC1967NonPayable--}[`++ERC1967NonPayable()++`]
  289. --
  290. [.contract-item]
  291. [[ERC1967Utils-getImplementation--]]
  292. ==== `[.contract-item-name]#++getImplementation++#++() → address++` [.item-kind]#internal#
  293. Returns the current implementation address.
  294. [.contract-item]
  295. [[ERC1967Utils-upgradeToAndCall-address-bytes-]]
  296. ==== `[.contract-item-name]#++upgradeToAndCall++#++(address newImplementation, bytes data)++` [.item-kind]#internal#
  297. Performs implementation upgrade with additional setup call if data is nonempty.
  298. This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
  299. to avoid stuck value in the contract.
  300. Emits an {IERC1967-Upgraded} event.
  301. [.contract-item]
  302. [[ERC1967Utils-getAdmin--]]
  303. ==== `[.contract-item-name]#++getAdmin++#++() → address++` [.item-kind]#internal#
  304. Returns the current admin.
  305. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
  306. the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
  307. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
  308. [.contract-item]
  309. [[ERC1967Utils-changeAdmin-address-]]
  310. ==== `[.contract-item-name]#++changeAdmin++#++(address newAdmin)++` [.item-kind]#internal#
  311. Changes the admin of the proxy.
  312. Emits an {IERC1967-AdminChanged} event.
  313. [.contract-item]
  314. [[ERC1967Utils-getBeacon--]]
  315. ==== `[.contract-item-name]#++getBeacon++#++() → address++` [.item-kind]#internal#
  316. Returns the current beacon.
  317. [.contract-item]
  318. [[ERC1967Utils-upgradeBeaconToAndCall-address-bytes-]]
  319. ==== `[.contract-item-name]#++upgradeBeaconToAndCall++#++(address newBeacon, bytes data)++` [.item-kind]#internal#
  320. Change the beacon and trigger a setup call if data is nonempty.
  321. This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
  322. to avoid stuck value in the contract.
  323. Emits an {IERC1967-BeaconUpgraded} event.
  324. CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
  325. it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
  326. efficiency.
  327. [.contract-item]
  328. [[ERC1967Utils-Upgraded-address-]]
  329. ==== `[.contract-item-name]#++Upgraded++#++(address indexed implementation)++` [.item-kind]#event#
  330. Emitted when the implementation is upgraded.
  331. [.contract-item]
  332. [[ERC1967Utils-AdminChanged-address-address-]]
  333. ==== `[.contract-item-name]#++AdminChanged++#++(address previousAdmin, address newAdmin)++` [.item-kind]#event#
  334. Emitted when the admin account has changed.
  335. [.contract-item]
  336. [[ERC1967Utils-BeaconUpgraded-address-]]
  337. ==== `[.contract-item-name]#++BeaconUpgraded++#++(address indexed beacon)++` [.item-kind]#event#
  338. Emitted when the beacon is changed.
  339. [.contract-item]
  340. [[ERC1967Utils-ERC1967InvalidImplementation-address-]]
  341. ==== `[.contract-item-name]#++ERC1967InvalidImplementation++#++(address implementation)++` [.item-kind]#error#
  342. The `implementation` of the proxy is invalid.
  343. [.contract-item]
  344. [[ERC1967Utils-ERC1967InvalidAdmin-address-]]
  345. ==== `[.contract-item-name]#++ERC1967InvalidAdmin++#++(address admin)++` [.item-kind]#error#
  346. The `admin` of the proxy is invalid.
  347. [.contract-item]
  348. [[ERC1967Utils-ERC1967InvalidBeacon-address-]]
  349. ==== `[.contract-item-name]#++ERC1967InvalidBeacon++#++(address beacon)++` [.item-kind]#error#
  350. The `beacon` of the proxy is invalid.
  351. [.contract-item]
  352. [[ERC1967Utils-ERC1967NonPayable--]]
  353. ==== `[.contract-item-name]#++ERC1967NonPayable++#++()++` [.item-kind]#error#
  354. An upgrade function sees `msg.value > 0` that may be lost.
  355. == Transparent Proxy
  356. :ProxyDeniedAdminAccess: pass:normal[xref:#TransparentUpgradeableProxy-ProxyDeniedAdminAccess--[`++ProxyDeniedAdminAccess++`]]
  357. :constructor: pass:normal[xref:#TransparentUpgradeableProxy-constructor-address-address-bytes-[`++constructor++`]]
  358. :_proxyAdmin: pass:normal[xref:#TransparentUpgradeableProxy-_proxyAdmin--[`++_proxyAdmin++`]]
  359. :_fallback: pass:normal[xref:#TransparentUpgradeableProxy-_fallback--[`++_fallback++`]]
  360. [.contract]
  361. [[TransparentUpgradeableProxy]]
  362. === `++TransparentUpgradeableProxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/transparent/TransparentUpgradeableProxy.sol[{github-icon},role=heading-link]
  363. [.hljs-theme-light.nopadding]
  364. ```solidity
  365. import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
  366. ```
  367. This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.
  368. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
  369. clashing], which can potentially be used in an attack, this contract uses the
  370. https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
  371. things that go hand in hand:
  372. 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
  373. that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
  374. 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to
  375. the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
  376. the proxy admin cannot fallback to the target implementation.
  377. These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
  378. dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
  379. call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and
  380. allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
  381. interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.
  382. NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
  383. inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
  384. mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
  385. fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
  386. implementation.
  387. NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a
  388. meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
  389. IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an
  390. immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
  391. overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
  392. undesirable state where the admin slot is different from the actual admin.
  393. WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the
  394. compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
  395. function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This
  396. could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
  397. [.contract-index]
  398. .Functions
  399. --
  400. * {xref-TransparentUpgradeableProxy-constructor-address-address-bytes-}[`++constructor(_logic, initialOwner, _data)++`]
  401. * {xref-TransparentUpgradeableProxy-_proxyAdmin--}[`++_proxyAdmin()++`]
  402. * {xref-TransparentUpgradeableProxy-_fallback--}[`++_fallback()++`]
  403. [.contract-subindex-inherited]
  404. .ERC1967Proxy
  405. * {xref-ERC1967Proxy-_implementation--}[`++_implementation()++`]
  406. [.contract-subindex-inherited]
  407. .Proxy
  408. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  409. * {xref-Proxy-fallback--}[`++fallback()++`]
  410. --
  411. [.contract-index]
  412. .Errors
  413. --
  414. * {xref-TransparentUpgradeableProxy-ProxyDeniedAdminAccess--}[`++ProxyDeniedAdminAccess()++`]
  415. [.contract-subindex-inherited]
  416. .ERC1967Proxy
  417. [.contract-subindex-inherited]
  418. .Proxy
  419. --
  420. [.contract-item]
  421. [[TransparentUpgradeableProxy-constructor-address-address-bytes-]]
  422. ==== `[.contract-item-name]#++constructor++#++(address _logic, address initialOwner, bytes _data)++` [.item-kind]#public#
  423. Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
  424. backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
  425. {ERC1967Proxy-constructor}.
  426. [.contract-item]
  427. [[TransparentUpgradeableProxy-_proxyAdmin--]]
  428. ==== `[.contract-item-name]#++_proxyAdmin++#++() → address++` [.item-kind]#internal#
  429. Returns the admin of this proxy.
  430. [.contract-item]
  431. [[TransparentUpgradeableProxy-_fallback--]]
  432. ==== `[.contract-item-name]#++_fallback++#++()++` [.item-kind]#internal#
  433. If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
  434. [.contract-item]
  435. [[TransparentUpgradeableProxy-ProxyDeniedAdminAccess--]]
  436. ==== `[.contract-item-name]#++ProxyDeniedAdminAccess++#++()++` [.item-kind]#error#
  437. The proxy caller is the current admin, and can't fallback to the proxy target.
  438. :UPGRADE_INTERFACE_VERSION: pass:normal[xref:#ProxyAdmin-UPGRADE_INTERFACE_VERSION-string[`++UPGRADE_INTERFACE_VERSION++`]]
  439. :constructor: pass:normal[xref:#ProxyAdmin-constructor-address-[`++constructor++`]]
  440. :upgradeAndCall: pass:normal[xref:#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-[`++upgradeAndCall++`]]
  441. [.contract]
  442. [[ProxyAdmin]]
  443. === `++ProxyAdmin++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/transparent/ProxyAdmin.sol[{github-icon},role=heading-link]
  444. [.hljs-theme-light.nopadding]
  445. ```solidity
  446. import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
  447. ```
  448. This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
  449. explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
  450. [.contract-index]
  451. .Functions
  452. --
  453. * {xref-ProxyAdmin-constructor-address-}[`++constructor(initialOwner)++`]
  454. * {xref-ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-}[`++upgradeAndCall(proxy, implementation, data)++`]
  455. [.contract-subindex-inherited]
  456. .Ownable
  457. * {xref-Ownable-owner--}[`++owner()++`]
  458. * {xref-Ownable-_checkOwner--}[`++_checkOwner()++`]
  459. * {xref-Ownable-renounceOwnership--}[`++renounceOwnership()++`]
  460. * {xref-Ownable-transferOwnership-address-}[`++transferOwnership(newOwner)++`]
  461. * {xref-Ownable-_transferOwnership-address-}[`++_transferOwnership(newOwner)++`]
  462. --
  463. [.contract-index]
  464. .Events
  465. --
  466. [.contract-subindex-inherited]
  467. .Ownable
  468. * {xref-Ownable-OwnershipTransferred-address-address-}[`++OwnershipTransferred(previousOwner, newOwner)++`]
  469. --
  470. [.contract-index]
  471. .Errors
  472. --
  473. [.contract-subindex-inherited]
  474. .Ownable
  475. * {xref-Ownable-OwnableUnauthorizedAccount-address-}[`++OwnableUnauthorizedAccount(account)++`]
  476. * {xref-Ownable-OwnableInvalidOwner-address-}[`++OwnableInvalidOwner(owner)++`]
  477. --
  478. [.contract-item]
  479. [[ProxyAdmin-constructor-address-]]
  480. ==== `[.contract-item-name]#++constructor++#++(address initialOwner)++` [.item-kind]#public#
  481. Sets the initial owner who can perform upgrades.
  482. [.contract-item]
  483. [[ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-]]
  484. ==== `[.contract-item-name]#++upgradeAndCall++#++(contract ITransparentUpgradeableProxy proxy, address implementation, bytes data)++` [.item-kind]#public#
  485. Upgrades `proxy` to `implementation` and calls a function on the new implementation.
  486. See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
  487. Requirements:
  488. - This contract must be the admin of `proxy`.
  489. - If `data` is empty, `msg.value` must be zero.
  490. == Beacon
  491. :constructor: pass:normal[xref:#BeaconProxy-constructor-address-bytes-[`++constructor++`]]
  492. :_implementation: pass:normal[xref:#BeaconProxy-_implementation--[`++_implementation++`]]
  493. :_getBeacon: pass:normal[xref:#BeaconProxy-_getBeacon--[`++_getBeacon++`]]
  494. [.contract]
  495. [[BeaconProxy]]
  496. === `++BeaconProxy++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/beacon/BeaconProxy.sol[{github-icon},role=heading-link]
  497. [.hljs-theme-light.nopadding]
  498. ```solidity
  499. import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
  500. ```
  501. This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
  502. The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
  503. immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
  504. https://eips.ethereum.org/EIPS/eip-1967[EIP1967] so that it can be accessed externally.
  505. CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
  506. the beacon to not upgrade the implementation maliciously.
  507. IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
  508. an inconsistent state where the beacon storage slot does not match the beacon address.
  509. [.contract-index]
  510. .Functions
  511. --
  512. * {xref-BeaconProxy-constructor-address-bytes-}[`++constructor(beacon, data)++`]
  513. * {xref-BeaconProxy-_implementation--}[`++_implementation()++`]
  514. * {xref-BeaconProxy-_getBeacon--}[`++_getBeacon()++`]
  515. [.contract-subindex-inherited]
  516. .Proxy
  517. * {xref-Proxy-_delegate-address-}[`++_delegate(implementation)++`]
  518. * {xref-Proxy-_fallback--}[`++_fallback()++`]
  519. * {xref-Proxy-fallback--}[`++fallback()++`]
  520. --
  521. [.contract-item]
  522. [[BeaconProxy-constructor-address-bytes-]]
  523. ==== `[.contract-item-name]#++constructor++#++(address beacon, bytes data)++` [.item-kind]#public#
  524. Initializes the proxy with `beacon`.
  525. If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
  526. will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
  527. constructor.
  528. Requirements:
  529. - `beacon` must be a contract with the interface {IBeacon}.
  530. - If `data` is empty, `msg.value` must be zero.
  531. [.contract-item]
  532. [[BeaconProxy-_implementation--]]
  533. ==== `[.contract-item-name]#++_implementation++#++() → address++` [.item-kind]#internal#
  534. Returns the current implementation address of the associated beacon.
  535. [.contract-item]
  536. [[BeaconProxy-_getBeacon--]]
  537. ==== `[.contract-item-name]#++_getBeacon++#++() → address++` [.item-kind]#internal#
  538. Returns the beacon.
  539. :implementation: pass:normal[xref:#IBeacon-implementation--[`++implementation++`]]
  540. [.contract]
  541. [[IBeacon]]
  542. === `++IBeacon++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/beacon/IBeacon.sol[{github-icon},role=heading-link]
  543. [.hljs-theme-light.nopadding]
  544. ```solidity
  545. import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
  546. ```
  547. This is the interface that {BeaconProxy} expects of its beacon.
  548. [.contract-index]
  549. .Functions
  550. --
  551. * {xref-IBeacon-implementation--}[`++implementation()++`]
  552. --
  553. [.contract-item]
  554. [[IBeacon-implementation--]]
  555. ==== `[.contract-item-name]#++implementation++#++() → address++` [.item-kind]#external#
  556. Must return an address that can be used as a delegate call target.
  557. {UpgradeableBeacon} will check that this address is a contract.
  558. :BeaconInvalidImplementation: pass:normal[xref:#UpgradeableBeacon-BeaconInvalidImplementation-address-[`++BeaconInvalidImplementation++`]]
  559. :Upgraded: pass:normal[xref:#UpgradeableBeacon-Upgraded-address-[`++Upgraded++`]]
  560. :constructor: pass:normal[xref:#UpgradeableBeacon-constructor-address-address-[`++constructor++`]]
  561. :implementation: pass:normal[xref:#UpgradeableBeacon-implementation--[`++implementation++`]]
  562. :upgradeTo: pass:normal[xref:#UpgradeableBeacon-upgradeTo-address-[`++upgradeTo++`]]
  563. [.contract]
  564. [[UpgradeableBeacon]]
  565. === `++UpgradeableBeacon++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/beacon/UpgradeableBeacon.sol[{github-icon},role=heading-link]
  566. [.hljs-theme-light.nopadding]
  567. ```solidity
  568. import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
  569. ```
  570. This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
  571. implementation contract, which is where they will delegate all function calls.
  572. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
  573. [.contract-index]
  574. .Functions
  575. --
  576. * {xref-UpgradeableBeacon-constructor-address-address-}[`++constructor(implementation_, initialOwner)++`]
  577. * {xref-UpgradeableBeacon-implementation--}[`++implementation()++`]
  578. * {xref-UpgradeableBeacon-upgradeTo-address-}[`++upgradeTo(newImplementation)++`]
  579. [.contract-subindex-inherited]
  580. .Ownable
  581. * {xref-Ownable-owner--}[`++owner()++`]
  582. * {xref-Ownable-_checkOwner--}[`++_checkOwner()++`]
  583. * {xref-Ownable-renounceOwnership--}[`++renounceOwnership()++`]
  584. * {xref-Ownable-transferOwnership-address-}[`++transferOwnership(newOwner)++`]
  585. * {xref-Ownable-_transferOwnership-address-}[`++_transferOwnership(newOwner)++`]
  586. [.contract-subindex-inherited]
  587. .IBeacon
  588. --
  589. [.contract-index]
  590. .Events
  591. --
  592. * {xref-UpgradeableBeacon-Upgraded-address-}[`++Upgraded(implementation)++`]
  593. [.contract-subindex-inherited]
  594. .Ownable
  595. * {xref-Ownable-OwnershipTransferred-address-address-}[`++OwnershipTransferred(previousOwner, newOwner)++`]
  596. [.contract-subindex-inherited]
  597. .IBeacon
  598. --
  599. [.contract-index]
  600. .Errors
  601. --
  602. * {xref-UpgradeableBeacon-BeaconInvalidImplementation-address-}[`++BeaconInvalidImplementation(implementation)++`]
  603. [.contract-subindex-inherited]
  604. .Ownable
  605. * {xref-Ownable-OwnableUnauthorizedAccount-address-}[`++OwnableUnauthorizedAccount(account)++`]
  606. * {xref-Ownable-OwnableInvalidOwner-address-}[`++OwnableInvalidOwner(owner)++`]
  607. [.contract-subindex-inherited]
  608. .IBeacon
  609. --
  610. [.contract-item]
  611. [[UpgradeableBeacon-constructor-address-address-]]
  612. ==== `[.contract-item-name]#++constructor++#++(address implementation_, address initialOwner)++` [.item-kind]#public#
  613. Sets the address of the initial implementation, and the initial owner who can upgrade the beacon.
  614. [.contract-item]
  615. [[UpgradeableBeacon-implementation--]]
  616. ==== `[.contract-item-name]#++implementation++#++() → address++` [.item-kind]#public#
  617. Returns the current implementation address.
  618. [.contract-item]
  619. [[UpgradeableBeacon-upgradeTo-address-]]
  620. ==== `[.contract-item-name]#++upgradeTo++#++(address newImplementation)++` [.item-kind]#public#
  621. Upgrades the beacon to a new implementation.
  622. Emits an {Upgraded} event.
  623. Requirements:
  624. - msg.sender must be the owner of the contract.
  625. - `newImplementation` must be a contract.
  626. [.contract-item]
  627. [[UpgradeableBeacon-Upgraded-address-]]
  628. ==== `[.contract-item-name]#++Upgraded++#++(address indexed implementation)++` [.item-kind]#event#
  629. Emitted when the implementation returned by the beacon is changed.
  630. [.contract-item]
  631. [[UpgradeableBeacon-BeaconInvalidImplementation-address-]]
  632. ==== `[.contract-item-name]#++BeaconInvalidImplementation++#++(address implementation)++` [.item-kind]#error#
  633. The `implementation` of the beacon is invalid.
  634. == Minimal Clones
  635. :ERC1167FailedCreateClone: pass:normal[xref:#Clones-ERC1167FailedCreateClone--[`++ERC1167FailedCreateClone++`]]
  636. :clone: pass:normal[xref:#Clones-clone-address-[`++clone++`]]
  637. :cloneDeterministic: pass:normal[xref:#Clones-cloneDeterministic-address-bytes32-[`++cloneDeterministic++`]]
  638. :predictDeterministicAddress: pass:normal[xref:#Clones-predictDeterministicAddress-address-bytes32-address-[`++predictDeterministicAddress++`]]
  639. :predictDeterministicAddress: pass:normal[xref:#Clones-predictDeterministicAddress-address-bytes32-[`++predictDeterministicAddress++`]]
  640. [.contract]
  641. [[Clones]]
  642. === `++Clones++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/Clones.sol[{github-icon},role=heading-link]
  643. [.hljs-theme-light.nopadding]
  644. ```solidity
  645. import "@openzeppelin/contracts/proxy/Clones.sol";
  646. ```
  647. https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
  648. deploying minimal proxy contracts, also known as "clones".
  649. > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
  650. > a minimal bytecode implementation that delegates all calls to a known, fixed address.
  651. The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
  652. (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
  653. deterministic method.
  654. [.contract-index]
  655. .Functions
  656. --
  657. * {xref-Clones-clone-address-}[`++clone(implementation)++`]
  658. * {xref-Clones-cloneDeterministic-address-bytes32-}[`++cloneDeterministic(implementation, salt)++`]
  659. * {xref-Clones-predictDeterministicAddress-address-bytes32-address-}[`++predictDeterministicAddress(implementation, salt, deployer)++`]
  660. * {xref-Clones-predictDeterministicAddress-address-bytes32-}[`++predictDeterministicAddress(implementation, salt)++`]
  661. --
  662. [.contract-index]
  663. .Errors
  664. --
  665. * {xref-Clones-ERC1167FailedCreateClone--}[`++ERC1167FailedCreateClone()++`]
  666. --
  667. [.contract-item]
  668. [[Clones-clone-address-]]
  669. ==== `[.contract-item-name]#++clone++#++(address implementation) → address instance++` [.item-kind]#internal#
  670. Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
  671. This function uses the create opcode, which should never revert.
  672. [.contract-item]
  673. [[Clones-cloneDeterministic-address-bytes32-]]
  674. ==== `[.contract-item-name]#++cloneDeterministic++#++(address implementation, bytes32 salt) → address instance++` [.item-kind]#internal#
  675. Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
  676. This function uses the create2 opcode and a `salt` to deterministically deploy
  677. the clone. Using the same `implementation` and `salt` multiple time will revert, since
  678. the clones cannot be deployed twice at the same address.
  679. [.contract-item]
  680. [[Clones-predictDeterministicAddress-address-bytes32-address-]]
  681. ==== `[.contract-item-name]#++predictDeterministicAddress++#++(address implementation, bytes32 salt, address deployer) → address predicted++` [.item-kind]#internal#
  682. Computes the address of a clone deployed using {Clones-cloneDeterministic}.
  683. [.contract-item]
  684. [[Clones-predictDeterministicAddress-address-bytes32-]]
  685. ==== `[.contract-item-name]#++predictDeterministicAddress++#++(address implementation, bytes32 salt) → address predicted++` [.item-kind]#internal#
  686. Computes the address of a clone deployed using {Clones-cloneDeterministic}.
  687. [.contract-item]
  688. [[Clones-ERC1167FailedCreateClone--]]
  689. ==== `[.contract-item-name]#++ERC1167FailedCreateClone++#++()++` [.item-kind]#error#
  690. A clone instance deployment failed.
  691. == Utils
  692. :InitializableStorage: pass:normal[xref:#Initializable-InitializableStorage[`++InitializableStorage++`]]
  693. :InvalidInitialization: pass:normal[xref:#Initializable-InvalidInitialization--[`++InvalidInitialization++`]]
  694. :NotInitializing: pass:normal[xref:#Initializable-NotInitializing--[`++NotInitializing++`]]
  695. :Initialized: pass:normal[xref:#Initializable-Initialized-uint64-[`++Initialized++`]]
  696. :initializer: pass:normal[xref:#Initializable-initializer--[`++initializer++`]]
  697. :reinitializer: pass:normal[xref:#Initializable-reinitializer-uint64-[`++reinitializer++`]]
  698. :onlyInitializing: pass:normal[xref:#Initializable-onlyInitializing--[`++onlyInitializing++`]]
  699. :_checkInitializing: pass:normal[xref:#Initializable-_checkInitializing--[`++_checkInitializing++`]]
  700. :_disableInitializers: pass:normal[xref:#Initializable-_disableInitializers--[`++_disableInitializers++`]]
  701. :_getInitializedVersion: pass:normal[xref:#Initializable-_getInitializedVersion--[`++_getInitializedVersion++`]]
  702. :_isInitializing: pass:normal[xref:#Initializable-_isInitializing--[`++_isInitializing++`]]
  703. [.contract]
  704. [[Initializable]]
  705. === `++Initializable++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/utils/Initializable.sol[{github-icon},role=heading-link]
  706. [.hljs-theme-light.nopadding]
  707. ```solidity
  708. import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
  709. ```
  710. This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
  711. behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
  712. external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
  713. function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
  714. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
  715. reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
  716. case an upgrade adds a module that needs to be initialized.
  717. For example:
  718. [.hljs-theme-light.nopadding]
  719. ```solidity
  720. contract MyToken is ERC20Upgradeable {
  721. function initialize() initializer public {
  722. __ERC20_init("MyToken", "MTK");
  723. }
  724. }
  725. contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
  726. function initializeV2() reinitializer(2) public {
  727. __ERC20Permit_init("MyToken");
  728. }
  729. }
  730. ```
  731. TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
  732. possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
  733. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
  734. that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
  735. [CAUTION]
  736. ====
  737. Avoid leaving a contract uninitialized.
  738. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
  739. contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
  740. the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
  741. [.hljs-theme-light.nopadding]
  742. ```
  743. /// @custom:oz-upgrades-unsafe-allow constructor
  744. constructor() {
  745. _disableInitializers();
  746. }
  747. ```
  748. ====
  749. [.contract-index]
  750. .Modifiers
  751. --
  752. * {xref-Initializable-initializer--}[`++initializer()++`]
  753. * {xref-Initializable-reinitializer-uint64-}[`++reinitializer(version)++`]
  754. * {xref-Initializable-onlyInitializing--}[`++onlyInitializing()++`]
  755. --
  756. [.contract-index]
  757. .Functions
  758. --
  759. * {xref-Initializable-_checkInitializing--}[`++_checkInitializing()++`]
  760. * {xref-Initializable-_disableInitializers--}[`++_disableInitializers()++`]
  761. * {xref-Initializable-_getInitializedVersion--}[`++_getInitializedVersion()++`]
  762. * {xref-Initializable-_isInitializing--}[`++_isInitializing()++`]
  763. --
  764. [.contract-index]
  765. .Events
  766. --
  767. * {xref-Initializable-Initialized-uint64-}[`++Initialized(version)++`]
  768. --
  769. [.contract-index]
  770. .Errors
  771. --
  772. * {xref-Initializable-InvalidInitialization--}[`++InvalidInitialization()++`]
  773. * {xref-Initializable-NotInitializing--}[`++NotInitializing()++`]
  774. --
  775. [.contract-item]
  776. [[Initializable-initializer--]]
  777. ==== `[.contract-item-name]#++initializer++#++()++` [.item-kind]#modifier#
  778. A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
  779. `onlyInitializing` functions can be used to initialize parent contracts.
  780. Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
  781. number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
  782. production.
  783. Emits an {Initialized} event.
  784. [.contract-item]
  785. [[Initializable-reinitializer-uint64-]]
  786. ==== `[.contract-item-name]#++reinitializer++#++(uint64 version)++` [.item-kind]#modifier#
  787. A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
  788. contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
  789. used to initialize parent contracts.
  790. A reinitializer may be used after the original initialization step. This is essential to configure modules that
  791. are added through upgrades and that require initialization.
  792. When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
  793. cannot be nested. If one is invoked in the context of another, execution will revert.
  794. Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
  795. a contract, executing them in the right order is up to the developer or operator.
  796. WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
  797. Emits an {Initialized} event.
  798. [.contract-item]
  799. [[Initializable-onlyInitializing--]]
  800. ==== `[.contract-item-name]#++onlyInitializing++#++()++` [.item-kind]#modifier#
  801. Modifier to protect an initialization function so that it can only be invoked by functions with the
  802. {initializer} and {reinitializer} modifiers, directly or indirectly.
  803. [.contract-item]
  804. [[Initializable-_checkInitializing--]]
  805. ==== `[.contract-item-name]#++_checkInitializing++#++()++` [.item-kind]#internal#
  806. Reverts if the contract is not in an initializing state. See {onlyInitializing}.
  807. [.contract-item]
  808. [[Initializable-_disableInitializers--]]
  809. ==== `[.contract-item-name]#++_disableInitializers++#++()++` [.item-kind]#internal#
  810. Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
  811. Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
  812. to any version. It is recommended to use this to lock implementation contracts that are designed to be called
  813. through proxies.
  814. Emits an {Initialized} event the first time it is successfully executed.
  815. [.contract-item]
  816. [[Initializable-_getInitializedVersion--]]
  817. ==== `[.contract-item-name]#++_getInitializedVersion++#++() → uint64++` [.item-kind]#internal#
  818. Returns the highest version that has been initialized. See {reinitializer}.
  819. [.contract-item]
  820. [[Initializable-_isInitializing--]]
  821. ==== `[.contract-item-name]#++_isInitializing++#++() → bool++` [.item-kind]#internal#
  822. Returns `true` if the contract is currently initializing. See {onlyInitializing}.
  823. [.contract-item]
  824. [[Initializable-Initialized-uint64-]]
  825. ==== `[.contract-item-name]#++Initialized++#++(uint64 version)++` [.item-kind]#event#
  826. Triggered when the contract has been initialized or reinitialized.
  827. [.contract-item]
  828. [[Initializable-InvalidInitialization--]]
  829. ==== `[.contract-item-name]#++InvalidInitialization++#++()++` [.item-kind]#error#
  830. The contract is already initialized.
  831. [.contract-item]
  832. [[Initializable-NotInitializing--]]
  833. ==== `[.contract-item-name]#++NotInitializing++#++()++` [.item-kind]#error#
  834. The contract is not initializing.
  835. :UPGRADE_INTERFACE_VERSION: pass:normal[xref:#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string[`++UPGRADE_INTERFACE_VERSION++`]]
  836. :UUPSUnauthorizedCallContext: pass:normal[xref:#UUPSUpgradeable-UUPSUnauthorizedCallContext--[`++UUPSUnauthorizedCallContext++`]]
  837. :UUPSUnsupportedProxiableUUID: pass:normal[xref:#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-[`++UUPSUnsupportedProxiableUUID++`]]
  838. :onlyProxy: pass:normal[xref:#UUPSUpgradeable-onlyProxy--[`++onlyProxy++`]]
  839. :notDelegated: pass:normal[xref:#UUPSUpgradeable-notDelegated--[`++notDelegated++`]]
  840. :proxiableUUID: pass:normal[xref:#UUPSUpgradeable-proxiableUUID--[`++proxiableUUID++`]]
  841. :upgradeToAndCall: pass:normal[xref:#UUPSUpgradeable-upgradeToAndCall-address-bytes-[`++upgradeToAndCall++`]]
  842. :_checkProxy: pass:normal[xref:#UUPSUpgradeable-_checkProxy--[`++_checkProxy++`]]
  843. :_checkNotDelegated: pass:normal[xref:#UUPSUpgradeable-_checkNotDelegated--[`++_checkNotDelegated++`]]
  844. :_authorizeUpgrade: pass:normal[xref:#UUPSUpgradeable-_authorizeUpgrade-address-[`++_authorizeUpgrade++`]]
  845. [.contract]
  846. [[UUPSUpgradeable]]
  847. === `++UUPSUpgradeable++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0-rc.0/contracts/proxy/utils/UUPSUpgradeable.sol[{github-icon},role=heading-link]
  848. [.hljs-theme-light.nopadding]
  849. ```solidity
  850. import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
  851. ```
  852. An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
  853. {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
  854. A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
  855. reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
  856. `UUPSUpgradeable` with a custom implementation of upgrades.
  857. The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
  858. @custom:stateless
  859. [.contract-index]
  860. .Modifiers
  861. --
  862. * {xref-UUPSUpgradeable-onlyProxy--}[`++onlyProxy()++`]
  863. * {xref-UUPSUpgradeable-notDelegated--}[`++notDelegated()++`]
  864. --
  865. [.contract-index]
  866. .Functions
  867. --
  868. * {xref-UUPSUpgradeable-proxiableUUID--}[`++proxiableUUID()++`]
  869. * {xref-UUPSUpgradeable-upgradeToAndCall-address-bytes-}[`++upgradeToAndCall(newImplementation, data)++`]
  870. * {xref-UUPSUpgradeable-_checkProxy--}[`++_checkProxy()++`]
  871. * {xref-UUPSUpgradeable-_checkNotDelegated--}[`++_checkNotDelegated()++`]
  872. * {xref-UUPSUpgradeable-_authorizeUpgrade-address-}[`++_authorizeUpgrade(newImplementation)++`]
  873. [.contract-subindex-inherited]
  874. .IERC1822Proxiable
  875. --
  876. [.contract-index]
  877. .Errors
  878. --
  879. * {xref-UUPSUpgradeable-UUPSUnauthorizedCallContext--}[`++UUPSUnauthorizedCallContext()++`]
  880. * {xref-UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-}[`++UUPSUnsupportedProxiableUUID(slot)++`]
  881. [.contract-subindex-inherited]
  882. .IERC1822Proxiable
  883. --
  884. [.contract-item]
  885. [[UUPSUpgradeable-onlyProxy--]]
  886. ==== `[.contract-item-name]#++onlyProxy++#++()++` [.item-kind]#modifier#
  887. Check that the execution is being performed through a delegatecall call and that the execution context is
  888. a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
  889. for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
  890. function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
  891. fail.
  892. [.contract-item]
  893. [[UUPSUpgradeable-notDelegated--]]
  894. ==== `[.contract-item-name]#++notDelegated++#++()++` [.item-kind]#modifier#
  895. Check that the execution is not being performed through a delegate call. This allows a function to be
  896. callable on the implementing contract but not through proxies.
  897. [.contract-item]
  898. [[UUPSUpgradeable-proxiableUUID--]]
  899. ==== `[.contract-item-name]#++proxiableUUID++#++() → bytes32++` [.item-kind]#external#
  900. Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
  901. implementation. It is used to validate the implementation's compatibility when performing an upgrade.
  902. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
  903. bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
  904. function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
  905. [.contract-item]
  906. [[UUPSUpgradeable-upgradeToAndCall-address-bytes-]]
  907. ==== `[.contract-item-name]#++upgradeToAndCall++#++(address newImplementation, bytes data)++` [.item-kind]#public#
  908. Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
  909. encoded in `data`.
  910. Calls {_authorizeUpgrade}.
  911. Emits an {Upgraded} event.
  912. [.contract-item]
  913. [[UUPSUpgradeable-_checkProxy--]]
  914. ==== `[.contract-item-name]#++_checkProxy++#++()++` [.item-kind]#internal#
  915. Reverts if the execution is not performed via delegatecall or the execution
  916. context is not of a proxy with an ERC1967-compliant implementation pointing to self.
  917. See {_onlyProxy}.
  918. [.contract-item]
  919. [[UUPSUpgradeable-_checkNotDelegated--]]
  920. ==== `[.contract-item-name]#++_checkNotDelegated++#++()++` [.item-kind]#internal#
  921. Reverts if the execution is performed via delegatecall.
  922. See {notDelegated}.
  923. [.contract-item]
  924. [[UUPSUpgradeable-_authorizeUpgrade-address-]]
  925. ==== `[.contract-item-name]#++_authorizeUpgrade++#++(address newImplementation)++` [.item-kind]#internal#
  926. Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
  927. {upgradeToAndCall}.
  928. Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
  929. ```solidity
  930. function _authorizeUpgrade(address) internal onlyOwner {}
  931. ```
  932. [.contract-item]
  933. [[UUPSUpgradeable-UUPSUnauthorizedCallContext--]]
  934. ==== `[.contract-item-name]#++UUPSUnauthorizedCallContext++#++()++` [.item-kind]#error#
  935. The call is from an unauthorized context.
  936. [.contract-item]
  937. [[UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-]]
  938. ==== `[.contract-item-name]#++UUPSUnsupportedProxiableUUID++#++(bytes32 slot)++` [.item-kind]#error#
  939. The storage `slot` is unsupported as a UUID.