proxy.adoc 72 KB

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