proxy.adoc 64 KB

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